UVa10409

題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1350

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
#include <iostream>
#include <vector>

using namespace std;

int main(){
int n;
string cmd;
while(cin >> n){
if(n == 0) break;
int top = 1, north = 2, west = 3, down = 6, south = 5, east = 4;

while(n--){
cin >> cmd;
int tmp = top;
if(cmd == "north"){
top = south;
south = down;
down = north;
north = tmp;
}
else if(cmd == "south"){
top = north;
north = down;
down = south;
south = tmp;
}
else if(cmd == "east"){
top = west;
west = down;
down = east;
east = tmp;
}
else if(cmd == "west"){
top = east;
east = down;
down = west;
west = tmp;
}
}
cout << top << '\n';
}
}