#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define endl '\n'
const ll MOD = 1e9+7;
const ll INF = 1e16;
const ll MAX = 2 * 1e5;
int n,m;
char arr[101][101];
map<pair<int,int>, bool> visited;
bool DFS(int i, int j){
if(i < 0 || i >= n) return false;
if(j < 0 || j >= m) return false;
if(visited[{i,j}]) return false;
visited[{i,j}] = true;
if(arr[i][j] == '.' || arr[i][j] == 'o') return false;
if(arr[i][j] == 'x') return true;
if(arr[i][j] == 'v') return DFS(i+1, j);
if(arr[i][j] == '^') return DFS(i-1, j);
if(arr[i][j] == '>') return DFS(i, j+1);
if(arr[i][j] == '<') return DFS(i, j-1);
}
void solve(){
cin>>n>>m;
pair<int,int> start;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cin>>arr[i][j];
if(arr[i][j] == 'o') start = {i,j};
}
}
if(DFS(start.first + 1, start.second)){
cout<<":)\nS";
return;
}
if(DFS(start.first - 1, start.second)){
cout<<":)\nN";
return;
}
if(DFS(start.first, start.second - 1)){
cout<<":)\nW";
return;
}
if(DFS(start.first, start.second + 1)){
cout<<":)\nE";
return;
}else{
cout<<":(";
}
}
int main()
{
cin.tie(NULL);
ios::sync_with_stdio(NULL);
int t = 1;
//cin>>t;
int temp = t;
while(t--){
//cout<<"Case #"<<temp - t<<" > "<<endl;
solve();
cout<<endl;
}
cout.flush();
}
Compilation message
patkice.cpp: In function 'int main()':
patkice.cpp:76:9: warning: unused variable 'temp' [-Wunused-variable]
76 | int temp = t;
| ^~~~
patkice.cpp: In function 'bool DFS(int, int)':
patkice.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
31 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |