This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
char grid[100][100];
int n, m, sx, sy, dx, dy;
bool is_good(int x, int y) {
while (1) {
if (x == -1 || y == -1 || x == n || y == n) return 0;
else if (grid[x][y] == 'x') return 1;
else if (grid[x][y] == '^') x--;
else if (grid[x][y] == 'v') x++;
else if (grid[x][y] == '<') y--;
else if (grid[x][y] == '>') y++;
else return 0;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
cin >> grid[i][j];
if (grid[i][j] == 'o') sx = i, sy = j;
if (grid[i][j] == 'x') dx = i, dy = j;
}
if (is_good(sx + 1, sy)) return cout << ":)\nS", 0;
if (is_good(sx - 1, sy)) return cout << ":)\nN", 0;
if (is_good(sx, sy + 1)) return cout << ":)\nE", 0;
if (is_good(sx, sy - 1)) return cout << ":)\nW", 0;
cout << ":(";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |