#include <bits/stdc++.h>
using namespace std;
int r,c,ro,co,rx,cx;
char d[102][102];
int f(int rr,int cc,int l){
if(d[rr][cc]=='.' || d[rr][cc]=='o') return INT_MAX;
if(d[rr][cc]=='x') return l;
if(d[rr][cc]=='>') return f(rr,cc+1,l+1);
if(d[rr][cc]=='<') return f(rr,cc-1,l+1);
if(d[rr][cc]=='^') return f(rr-1,cc,l+1);
if(d[rr][cc]=='v') return f(rr+1,cc,l+1);
}
int main(){
cin>>r>>c;
for(int i=0;i<102;i++)
for(int j=0;j<102;j++)
d[i][j]='.';
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
cin>>d[i][j];
if(d[i][j]=='o'){
ro=i;
co=j;
}
}
}
int ps=f(ro+1,co,1);
int pn=f(ro-1,co,1);
int pe=f(ro,co+1,1);
int pw=f(ro,co-1,1);
int mp=min(ps,min(pn,min(pe,pw)));
//cout<<pn<<" "<<pe<<" "<<ps<<" "<<pw<<endl;
if(mp==INT_MAX) cout<<":(";
else if(mp==pe) cout<<":)\nE";
else if(mp==pn) cout<<":)\nN";
else if(mp==ps) cout<<":)\nS";
else if(mp==pw) cout<<":)\nW";
return 0;
}
/*
6 6
..>>>v
.o^..v
.v.<.v
.>>^.v
.x<<<<
......
*/
Compilation message
patkice.cpp: In function 'int f(int, int, int)':
patkice.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type]
13 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
300 KB |
Output is correct |
12 |
Correct |
1 ms |
276 KB |
Output is correct |
13 |
Correct |
1 ms |
296 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
300 KB |
Output is correct |
19 |
Correct |
0 ms |
296 KB |
Output is correct |
20 |
Correct |
0 ms |
296 KB |
Output is correct |