-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP11507.cpp
92 lines (87 loc) · 1.47 KB
/
P11507.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#define POSX 0
#define POSY 1
#define POSZ 2
#define NEGX 3
#define NEGY 4
#define NEGZ 5
int parse(const string &s) {
if(s[0] == '+') {
if(s[1] == 'y')
return POSY;
return POSZ;
}
else {
if(s[1] == 'y')
return NEGY;
return NEGZ;
}
}
int turnPosY(int from) {
if(from == POSZ || from == NEGZ)
return from;
if(from == POSX)
return POSY;
if(from == NEGX)
return NEGY;
if(from == POSY)
return NEGX;
return POSX;
}
int turnPosZ(int from) {
if(from == POSY || from == NEGY)
return from;
if(from == POSX)
return POSZ;
if(from == NEGX)
return NEGZ;
if(from == POSZ)
return NEGX;
return POSX;
}
int turn(int from, int dir) {
switch(dir) {
case POSY:
return turnPosY(from);
case NEGY:
return turnPosY(turnPosY(turnPosY(from)));
case POSZ:
return turnPosZ(from);
default:
return turnPosZ(turnPosZ(turnPosZ(from)));
}
// todo
}
int main() {
while(true) {
int L; cin >> L;
if(L == 0)
return 0;
int dir = POSX;
string s;
FORI(L-1) {
cin >> s;
if(s != "No")
dir = turn(dir, parse(s));
}
switch(dir) {
case POSX:
cout << "+x" << endl;
break;
case POSY:
cout << "+y" << endl;
break;
case POSZ:
cout << "+z" << endl;
break;
case NEGX:
cout << "-x" << endl;
break;
case NEGY:
cout << "-y" << endl;
break;
case NEGZ:
cout << "-z" << endl;
break;
}
}
}