Advertisement
Guest User

sol.cpp

a guest
Aug 16th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. // Nishinoya Kun
  2. #include <bits/stdc++.h>
  3.  
  4. #define sz(X) int(X.size())
  5. #define in "input.txt"
  6. #define out "output.txt"
  7. #define all(X) X.begin(), X.end()
  8. #define REP(it, base, dest) for (int it = (base); it < (dest); it++)
  9. #define PER(it, base, dest) for (int it = (base); it > (dest); it--)
  10.  
  11. const int N = int(1e3) + 500;
  12.  
  13. using namespace std;
  14.  
  15. int di[4] = {0, 0, 1, -1}, dj[4] = {1, -1, 0, 0};
  16. string path[4] = {"EAST", "WEST", "SOUTH", "NORTH"}, s;
  17. bool was[N][N], ok;
  18. void dfs(int i, int j) {
  19.     was[i][j] = true;
  20.     REP(pos, 0, 4) {
  21.         int newi = i + di[pos], newj = j + dj[pos];
  22.         if (!was[newi][newj]) {
  23.             cout << path[pos] << char(10);
  24.             cout.flush();
  25.             cin >> s;
  26.             if (s == "EMPTY") {    
  27.                 dfs(newi, newj);
  28.             }
  29.         }
  30.     }
  31. }
  32.  
  33. int main() {          
  34.     srand(time(NULL));
  35.     double start = clock();
  36.     //freopen(in, "r", stdin);                
  37.     //freopen(out, "w", stdout);
  38.     ios_base::sync_with_stdio(0);  
  39.     cin.tie(0);                    
  40.     // solve
  41.     dfs(30, 30);
  42.     cout << "DONE";
  43.     cerr << "Time " << (clock() - start)  * 1.0 / CLOCKS_PER_SEC << "s\n";                
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement