일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 이분 탐색
- 다이나믹 프로그래밍
- 포맷스트링버그
- tcache
- 연결리스트
- 브루트 포스
- heap
- 분할 정복
- 큐
- 동적 계획법
- 스위핑 알고리즘
- 이진 탐색
- 완전 탐색
- 수학
- 투 포인터
- syscall
- House of Orange
- OOB
- BFS
- RTL
- 스택
- fsb
- 문자열 처리
- DFS
- off by one
- BOF
- 에라토스테네스의 체
- 이진트리
- ROP
- 백트래킹
Archives
- Today
- Total
SDJ( 수돈재 아님 ㅎ )
[C++] 17013 - Flipper 본문
문제 링크 : https://www.acmicpc.net/problem/17013
17013번: Flipper
The input consists of one line, composed of a sequence of at least one and at most 1000000 characters. Each character is either H, representing a horizontal flip, or V, representing a vertical flip. For 8 of the 15 available marks, there will be at most 10
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include<iostream>
#include<algorithm>
#include<cstring>
#define endl '\n'
using namespace std;
int X[2][2] = {{1, 2}, {3, 4}};
char str[1000005];
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> str;
int tmp;
for(int i = 0; i < strlen(str); ++i)
{
while(str[i] == str[i+1] && i < strlen(str))
i = i+2;
if(str[i] == 'H')
{
tmp = X[0][0];
X[0][0] = X[1][0];
X[1][0] = tmp;
tmp = X[0][1];
X[0][1] = X[1][1];
X[1][1] = tmp;
}
else if(str[i] == 'V')
{
tmp = X[0][0];
X[0][0] = X[0][1];
X[0][1] = tmp;
tmp = X[1][0];
X[1][0] = X[1][1];
X[1][1] = tmp;
}
}
cout << X[0][0] << ' ' << X[0][1] << endl;
cout << X[1][0] << ' ' << X[1][1] << endl;
return 0;
}
|
'알고리즘 > Backjoon' 카테고리의 다른 글
[C] 1463 - 1로 만들기 (0) | 2020.01.09 |
---|---|
[C++] 15990 - 1, 2, 3 더하기 5 (0) | 2020.01.09 |
[C++] 17014 - Pretty Average Primes (0) | 2020.01.09 |
[C++] 17011 - Cold Compress (0) | 2020.01.09 |
[C++] 2659 - 십자카드 문제 (0) | 2020.01.09 |
Comments