SHARE
TWEET

Untitled

a guest Sep 19th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n, x, y;
  6. char c[200][200];
  7. bool u[200][200];
  8.  
  9. int main() {
  10.     cin >> n;
  11.     for (int i = 1; i <= n; i++) {
  12.         for (int j = 1; j <= n; j++) {
  13.             cin >> c[i][j];
  14.         }
  15.     }
  16.     cin >> x >> y;
  17.     while (1) {
  18.         if (x > n || x < 1 || y > n || y < 1) {
  19.             puts("0");
  20.             break;
  21.         }
  22.         if (u[x][y]) {
  23.             puts("-1");
  24.             break;
  25.         }
  26.         if (c[x][y] == '.') {
  27.             cout << x << " " << y << endl;
  28.             break;
  29.         }
  30.         u[x][y] = 1;
  31.         if (c[x][y] == 'N') x--;
  32.         if (c[x][y] == 'S') x++;
  33.         if (c[x][y] == 'E') y++;
  34.         if (c[x][y] == 'W') y--;
  35.     }
  36.  
  37.  
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top