Advertisement
Guest User

Untitled

a guest
Jan 10th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.42 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <string>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <vector>
  7. #include <stack>
  8. #include <queue>
  9. #include <list>
  10. #include <map>
  11. #include <set>
  12. #include <stdlib.h>
  13. #include <sstream>
  14. #include <assert.h>
  15. #include <memory.h>
  16. #include <complex>
  17. #include <time.h>
  18. #pragma comment(linker, "/STACK:100000000")
  19. using namespace std;
  20.  
  21. #define mp make_pair
  22. #define pb push_back
  23. #define ll long long
  24. #define sz(x) (int)(x).size()
  25.  
  26.  
  27. bool vis[66][66][5][5][5];
  28. bool stop = false;
  29. int itt = 0;
  30.  
  31. bool MOVE_LEFT() {
  32.     if(stop) return false;
  33.     cout << "MOVE LEFT" << endl;
  34. itt++;
  35.     string s;
  36.     cin >> s;
  37.     if(s == "EXIT") {
  38.         stop = true;
  39.         return true;
  40.     }
  41.     if(s == "OK") {
  42.         return true;
  43.     }
  44.     return false;
  45. }
  46.  
  47. bool MOVE_RIGHT() {
  48.     if(stop) return false;
  49.     cout << "MOVE RIGHT" << endl;
  50. itt++;
  51.     string s;
  52.     cin >> s;
  53.     if(s == "EXIT") {
  54.         stop = true;
  55.         return true;
  56.     }
  57.     if(s == "OK") {
  58.         return true;
  59.     }
  60.     return false;
  61. }
  62.  
  63. bool MOVE_DOWN() {
  64.     if(stop) return false;
  65.     cout << "MOVE DOWN" << endl;
  66. itt++;
  67.     string s;
  68.     cin >> s;
  69.     if(s == "EXIT") {
  70.         stop = true;
  71.         return true;
  72.     }
  73.     if(s == "OK") {
  74.         return true;
  75.     }
  76.     return false;
  77. }
  78.  
  79. bool MOVE_UP() {
  80.     if(stop) return false;
  81.     cout << "MOVE UP" << endl;
  82. itt++;
  83.     string s;
  84.     cin >> s;
  85.     if(s == "EXIT") {
  86.         stop = true;
  87.         return true;
  88.     }
  89.     if(s == "OK") {
  90.         return true;
  91.     }
  92.     return false;
  93. }
  94.  
  95. void go(int x, int y, int c1, int c2, int c3) {
  96.     if(stop) return;
  97.     if(vis[x][y][c1][c2][c3]) {
  98.         cout << "BACK" << endl;
  99. itt++;
  100.         string s;
  101.         cin >> s;
  102.         return;
  103.     }
  104.     vis[x][y][c1][c2][c3] = true;
  105.     if(stop) return;
  106.     if(!vis[x][y+1][c2][c3][1]) {
  107.         if(MOVE_LEFT()) {
  108.             if(stop) return;
  109.             go(x, y + 1, c2, c3, 1);
  110.         }
  111.     }
  112.     if(stop) return;
  113.     if(!vis[x+1][y][c2][c3][2]) {
  114.         if(MOVE_UP()) {
  115.             if(stop) return;
  116.             go(x + 1, y, c2, c3, 2);
  117.         }
  118.     }
  119.     if(stop) return;
  120.     if(!vis[x][y-1][c2][c3][3]) {
  121.         if(MOVE_RIGHT()) {
  122.             if(stop) return;
  123.             go(x, y - 1, c2, c3, 3);
  124.         }
  125.     }
  126.     if(stop) return;
  127.     if(!vis[x-1][y][c2][c3][4]) {
  128.         if(MOVE_DOWN()) {
  129.             if(stop) return;
  130.             go(x - 1, y, c2, c3, 4);
  131.         }
  132.     }
  133.     if(stop) return;
  134.     cout << "BACK" << endl;
  135. itt++;
  136.     string s;
  137.     cin >> s;
  138. }
  139.  
  140. int main() {
  141.     //freopen("palindrome.in","rt",stdin);
  142.     //freopen("palindrome.out","wt",stdout);
  143.    
  144.     int N, M;
  145.     scanf("%d %d", &N, &M);
  146.  
  147.     go(33, 33, 0, 0, 0);
  148. if(itt > 30000) assert(0);
  149.  
  150.  
  151.     return 0;
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement