# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
448125 |
2021-07-29T02:54:47 Z |
jk410 |
Patkice (COCI20_patkice) |
C++17 |
|
1 ms |
332 KB |
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
int N,M,sx,sy;
int dx[4]={0,-1,1,0},dy[4]={1,0,0,-1},Time[4];
bool Visited[100][100];
string A[100];
int dfs(int x,int y){
if (x<0||x>=N||y<0||y>=M||Visited[x][y]||A[x][y]=='.')
return INF;
if (A[x][y]=='x')
return 0;
Visited[x][y]=true;
for (int i=0; i<4; i++){
if (A[x][y]==">^v<"[i]){
int tmp=dfs(x+dx[i],y+dy[i]);
if (tmp==INF)
return INF;
return tmp+1;
}
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>N>>M;
for (int i=0; i<N; i++){
cin>>A[i];
for (int j=0; j<M; j++){
if (A[i][j]=='o'){
sx=i;
sy=j;
}
}
}
for (int i=0; i<4; i++){
memset(Visited,false,sizeof(Visited));
A[sx][sy]=">^v<"[i];
Time[i]=dfs(sx,sy);
}
int Min=INF,idx;
for (int i=0; i<4; i++){
if (Time[i]<Min){
Min=Time[i];
idx=i;
}
}
if (Min==INF)
cout<<":(";
else
cout<<":)\n"<<"ENSW"[idx];
return 0;
}
Compilation message
patkice.cpp: In function 'int dfs(int, int)':
patkice.cpp:22:1: warning: control reaches end of non-void function [-Wreturn-type]
22 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |