# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314856 | 2020-10-21T14:15:38 Z | model_code | Patkice (COCI20_patkice) | C++17 | 34 ms | 384 KB |
#include <cstdio> #include <algorithm> using namespace std; const int MAXN = 102; const int INF = MAXN*MAXN; typedef pair<int, int> ii; ii operator+(const ii& a, const ii& b){ return ii(a.first + b.first, a.second + b.second); } int r,s; char mat[MAXN][MAXN]; //ENSW ii delta[] = {ii(0, 1), ii(-1, 0), ii(1, 0), ii(0, -1)}; int measure(ii p){ int d = 0; for(;;){ switch(mat[p.first][p.second]){ case 'x': return d; case '>': p = p+delta[0]; break; case '^': p = p+delta[1]; break; case 'v': p = p+delta[2]; break; case '<': p = p+delta[3]; break; default: return INF; } d++; } return INF; } int main(){ scanf("%d%d", &r, &s); for(int i=0;i<r;i++){ scanf("%s", mat[i]); } ii start; for(int i=0;i<r;i++){ for(int j=0;j<s;j++){ if(mat[i][j] == 'o') start = ii(i, j); } } int bl = INF; char s = 0; for(int i=0;i<4;i++){ int len = measure(start + delta[i]); if(len<bl){ bl = len; s = "ENSW"[i]; } } if(s) printf(":)\n%c\n", s); else puts(":("); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 34 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 34 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 0 ms | 256 KB | Output is correct |