#include<bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
char M[N][N];
bool found = false;
string ans, path;
void dfs(int x, int y)
{
path += M[x][y];
if(M[x][y] == 'x')
{
found = true;
return;
}
if(M[x][y] == '^')
dfs(x - 1, y);
if(M[x][y] == 'v')
dfs(x + 1, y);
if(M[x][y] == '>')
dfs(x, y + 1);
if(M[x][y] == '<')
dfs(x, y - 1);
}
int main()
{
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i ++)
for(int j = 0; j < m ; j ++)
cin >> M[i][j];
pair<int,int> O;
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j ++)
if(M[i][j] == 'o')
O = {i, j};
dfs(O.first, O.second + 1);
if(found) {
cout << ":)\nE\n";
return 0;
}
dfs(O.first - 1, O.second);
if(found) {
cout << ":)\nN\n";
return 0;
}
dfs(O.first, O.second - 1);
if(found) {
cout << ":)\nW\n";
return 0;
}
dfs(O.first + 1, O.second);
if(found) {
cout << ":)\nS\n";
return 0;
}
cout << ":(\n";
return 0;
}
// ENSW
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |