p10409.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include <algorithm>
  2. #include <array>
  3. #include <iostream>
  4. #include <map>
  5. #include <utility>
  6. #include <vector>
  7. #include <iomanip>
  8. #include <sstream>
  9. #include <climits>
  10. #include <queue>
  11. #include <list>
  12. using namespace std;
  13. typedef unsigned int nat;
  14. class Die
  15. {
  16. public:
  17. Die() {}
  18. nat top() { return t; }
  19. void north()
  20. {
  21. nat temp = 7-n;
  22. n = t;
  23. t = temp;
  24. }
  25. void south()
  26. {
  27. nat temp = 7-t;
  28. t = n;
  29. n = temp;
  30. }
  31. void east()
  32. {
  33. nat temp = 7-t;
  34. t = w;
  35. w = temp;
  36. }
  37. void west()
  38. {
  39. nat temp = 7-w;
  40. w = t;
  41. t = temp;
  42. }
  43. private:
  44. nat t = 1, n = 2, w = 3;
  45. };
  46. int main()
  47. {
  48. nat tests;
  49. while(cin >> tests)
  50. {
  51. if(!tests)
  52. break;
  53. Die d;
  54. for(nat i = 0; i < tests; ++i)
  55. {
  56. string str;
  57. cin >> str;
  58. if(str == "north")
  59. d.north();
  60. else if(str == "east")
  61. d.east();
  62. else if(str == "south")
  63. d.south();
  64. else
  65. d.west();
  66. }
  67. cout << d.top() << endl;
  68. }
  69. return 0;
  70. }