Advertisement
cincout

Интерактивка про робота

Mar 23rd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4.  
  5. #define loop(x) for (int ui = 0; ui < x; ++ui)
  6.  
  7.  
  8. void up() {
  9. cout << "move north" << endl;
  10. }
  11.  
  12. void down() {
  13. cout << "move south" << endl;
  14. }
  15.  
  16. void left() {
  17. cout << "move west" << endl;
  18. }
  19.  
  20. void right() {
  21. cout << "move east" << endl;
  22. }
  23.  
  24. string rn[] = {"arrias", "eva", "leonid", "andrewzta"};
  25.  
  26. void echo() {
  27. cout << "echo " << rn[rand() % 4] << endl;
  28. }
  29.  
  30. string t;
  31.  
  32. string get() {
  33. string a;
  34. cin >> a;
  35. return a;
  36. }
  37.  
  38. void solve() {
  39. up(); // первое действие
  40. t = get();
  41. if (t == "found") {
  42. down(); // второе действие
  43. t = get();
  44. // еще 6 действий
  45. loop(7) {
  46. echo();
  47. t = get();
  48. }
  49. up();
  50. t = get();
  51. assert(t == "win");
  52. return;
  53. }
  54. right(); // второе действие
  55. t = get();
  56. if (t == "found") {
  57. left(); // третье действие
  58. t = get();
  59. loop(6) {
  60. echo();
  61. t = get();
  62. }
  63. right();
  64. t = get();
  65. assert(t == "win");
  66. return;
  67. }
  68. down(); // третье действие
  69. t = get();
  70. if (t == "found") {
  71. up(); // четвертое действие
  72. t = get();
  73. loop(5) {
  74. echo();
  75. t = get();
  76. }
  77. down();
  78. t = get();
  79. assert(t == "win");
  80. return;
  81. }
  82.  
  83. down(); // четвертое действие
  84. t = get();
  85. if (t == "found") {
  86. up(); // пятое действие
  87. t = get();
  88. loop(4) {
  89. echo();
  90. t = get();
  91. }
  92. down();
  93. t = get();
  94. assert(t == "win");
  95. return;
  96. }
  97.  
  98. left(); // пятое действие
  99. t = get();
  100. if (t == "found") {
  101. right(); // шестое действие
  102. t = get();
  103. loop(3) {
  104. echo();
  105. t = get();
  106. }
  107. left();
  108. t = get();
  109. assert(t == "win");
  110. return;
  111. }
  112.  
  113. left(); // шестое действие
  114. t = get();
  115. if (t == "found") {
  116. right(); // шестое действие
  117. t = get();
  118. loop(2) {
  119. echo();
  120. t = get();
  121. }
  122. left();
  123. t = get();
  124. assert(t == "win");
  125. return;
  126. }
  127.  
  128. up(); // седьмое действие
  129. t = get();
  130. if (t == "found") {
  131. down();
  132. t = get();
  133. loop(1) {
  134. echo();
  135. t = get();
  136. }
  137. up();
  138. t = get();
  139. assert(t == "win");
  140. return;
  141. }
  142.  
  143. up(); // восьмое действие
  144. t = get();
  145. if (t == "found") {
  146. down();
  147. t = get();
  148. up();
  149. t = get();
  150. assert(t == "win");
  151. return;
  152. }
  153.  
  154. right();
  155. t = get();
  156. down();
  157. t = get();
  158. assert(t == "win");
  159. return;
  160.  
  161. }
  162.  
  163. signed main() {
  164. ios::sync_with_stdio(false);
  165. cin.tie(0);
  166. solve();
  167. return 0;
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement