# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
870182 | 2023-11-07T07:30:32 Z | aeg | Patkice (COCI20_patkice) | C++14 | 1 ms | 688 KB |
#include<bits/stdc++.h> using namespace std; vector<string> a; int r,s; int f(int x, int y) { if(a[y][x] == 'x') return 0; if(a[y][x] == '.' || a[y][x] == 'o') return INT_MIN; int chx=0, chy=0; if(a[y][x]=='<') chx--; else if(a[y][x]=='>') chx++; else if(a[y][x]=='^') chy--; else chy++; int ans = f(x+chx, y+chy); if(ans < 0) return INT_MIN; return ans+1; } int main () { cin>>r>>s; a.assign(r,""); for(int i=0; i<r; i++) cin>>a[i]; int x, y; for(int i=0; i<r; i++) for(int j=0; j<s; j++) { if(a[i][j]=='o') { y=i; x=j; } } int N = f(x,y-1), S = f(x,y+1), W = f(x-1,y), E = f(x+1, y); int maxi = max(max(S,N),max(W,E)); int mini = INT_MAX; if(S >= 0) mini = min(mini, S); if(N >= 0) mini = min(mini, N); if(W >= 0) mini = min(mini, W); if(E >= 0) mini = min(mini, E); if(maxi < 0) { cout << ":(\n"; return 0; } cout << ":)\n"; if(S == mini) cout<<"S\n"; else if(N == mini) cout<<"N\n"; else if(W == mini) cout<<"W\n"; else cout<<"E\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 444 KB | Output is correct |
4 | Correct | 0 ms | 344 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 | Correct | 0 ms | 444 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 688 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 440 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Incorrect | 0 ms | 348 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |