-
Notifications
You must be signed in to change notification settings - Fork 1
/
13698.cpp
52 lines (42 loc) · 912 Bytes
/
13698.cpp
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
#include <iostream>
#include <string>
using namespace std;
int a(int x) {
return (x == 1 ? 2 : (x == 2 ? 1 : x));
}
int b(int x) {
return (x == 1 ? 3 : (x == 3 ? 1 : x));
}
int c(int x) {
return (x == 1 ? 4 : (x == 4 ? 1 : x));
}
int d(int x) {
return (x == 2 ? 3 : (x == 3 ? 2 : x));
}
int e(int x) {
return (x == 2 ? 4 : (x == 4 ? 2 : x));
}
int f(int x) {
return (x == 3 ? 4 : (x == 4 ? 3 : x));
}
void solve(void) {
string s; cin >> s;
int p = 1, q = 4;
for (char ch : s) {
switch (ch) {
case 'A': p = a(p); q = a(q); break;
case 'B': p = b(p); q = b(q); break;
case 'C': p = c(p); q = c(q); break;
case 'D': p = d(p); q = d(q); break;
case 'E': p = e(p); q = e(q); break;
case 'F': p = f(p); q = f(q); break;
}
}
cout << p << "\n" << q;
}
int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}