| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #include <algorithm>
- #include <array>
- #include <iostream>
- #include <map>
- #include <utility>
- #include <vector>
- #include <iomanip>
- #include <sstream>
- #include <climits>
- #include <queue>
- #include <list>
- using namespace std;
- typedef unsigned int nat;
- class Die
- {
- public:
- Die() {}
- nat top() { return t; }
- void north()
- {
- nat temp = 7-n;
- n = t;
- t = temp;
- }
- void south()
- {
- nat temp = 7-t;
- t = n;
- n = temp;
- }
- void east()
- {
- nat temp = 7-t;
- t = w;
- w = temp;
- }
- void west()
- {
- nat temp = 7-w;
- w = t;
- t = temp;
- }
- private:
- nat t = 1, n = 2, w = 3;
- };
- int main()
- {
- nat tests;
- while(cin >> tests)
- {
- if(!tests)
- break;
- Die d;
- for(nat i = 0; i < tests; ++i)
- {
- string str;
- cin >> str;
- if(str == "north")
- d.north();
- else if(str == "east")
- d.east();
- else if(str == "south")
- d.south();
- else
- d.west();
- }
- cout << d.top() << endl;
- }
- return 0;
- }
|