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 |
#include <iostream> #include <cstring> #include <string> #include <vector> #include <fstream> #include <map> #define INF 1000000000 using namespace std; int T,B,W,E,S,N; int Prev_T,Prev_N,Prev_B,Prev_S,Prev_W,Prev_E; int main() { int n; string cmd; while(cin>>n) { if(n==0) break; T=1;N=2;W=3; B=6;S=5;E=4; while(n--) { cin>>cmd; if(cmd=="north") { Prev_T=T;Prev_N=N;Prev_B=B;Prev_S=S; Prev_W=W;Prev_E=E; T = Prev_S; N = Prev_T;W=Prev_W; B = Prev_N;S=Prev_B;E=Prev_E; } else if(cmd=="south") { Prev_T=T;Prev_N=N;Prev_B=B;Prev_S=S; Prev_W=W;Prev_E=E; T = Prev_N; N = Prev_B;W=Prev_W; B = Prev_S; S=Prev_T;E=Prev_E; } else if(cmd=="east") { Prev_T=T;Prev_N=N;Prev_B=B;Prev_S=S; Prev_W=W;Prev_E=E; T = Prev_W; N = Prev_N;W=Prev_B; B = Prev_E; S=Prev_S;E=Prev_T; } else if(cmd=="west") { Prev_T=T;Prev_N=N;Prev_B=B;Prev_S=S; Prev_W=W;Prev_E=E; T = Prev_E; N = Prev_N;W=Prev_T; B = Prev_W; S=Prev_S;E=Prev_B; } } cout<<T<<"\n"; } return 0; } |