# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
196863 | 2020-01-17T10:17:30 Z | arnold518 | Nautilus (BOI19_nautilus) | C++14 | 1000 ms | 18660 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 500; const int MAXM = 5000; struct Point { int y, x; }; bool operator < (const Point &p, const Point &q) { return pii(p.x, p.y)<pii(q.x, q.y); } bool operator == (const Point &p, const Point &q) { return pii(p.x, p.y)==pii(q.x, q.y); } int R, C, M; char S[MAXN+10][MAXN+10], A[MAXM+10]; int main() { int i, j; scanf("%d%d%d", &R, &C, &M); for(i=1; i<=R; i++) scanf("%s", S[i]+1); scanf("%s", A+1); for(i=0; i<=R+1; i++) S[i][0]=S[i][C+1]='#'; for(i=0; i<=C+1; i++) S[0][i]=S[R+1][i]='#'; vector<Point> V; for(i=1; i<=R; i++) for(j=1; j<=C; j++) if(S[i][j]=='.') V.push_back({i, j}); for(i=1; i<=M; i++) { vector<Point> V2; for(auto it : V) { if(A[i]=='N') { Point nxt={it.y-1, it.x}; if(S[nxt.y][nxt.x]=='.') V2.push_back(nxt); } else if(A[i]=='S') { Point nxt={it.y+1, it.x}; if(S[nxt.y][nxt.x]=='.') V2.push_back(nxt); } else if(A[i]=='W') { Point nxt={it.y, it.x-1}; if(S[nxt.y][nxt.x]=='.') V2.push_back(nxt); } else if(A[i]=='E') { Point nxt={it.y, it.x+1}; if(S[nxt.y][nxt.x]=='.') V2.push_back(nxt); } else { Point nxt; nxt={it.y-1, it.x}; if(S[nxt.y][nxt.x]=='.') V2.push_back(nxt); nxt={it.y+1, it.x}; if(S[nxt.y][nxt.x]=='.') V2.push_back(nxt); nxt={it.y, it.x-1}; if(S[nxt.y][nxt.x]=='.') V2.push_back(nxt); nxt={it.y, it.x+1}; if(S[nxt.y][nxt.x]=='.') V2.push_back(nxt); } } sort(V2.begin(), V2.end()); V2.erase(unique(V2.begin(), V2.end()), V2.end()); V=V2; } printf("%d", V.size()); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 728 KB | Output is correct |
2 | Correct | 4 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 2 ms | 504 KB | Output is correct |
5 | Correct | 2 ms | 404 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 728 KB | Output is correct |
2 | Correct | 4 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 2 ms | 504 KB | Output is correct |
5 | Correct | 2 ms | 404 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 98 ms | 1348 KB | Output is correct |
8 | Correct | 19 ms | 704 KB | Output is correct |
9 | Correct | 6 ms | 504 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 186 ms | 1356 KB | Output is correct |
13 | Correct | 140 ms | 1112 KB | Output is correct |
14 | Correct | 73 ms | 780 KB | Output is correct |
15 | Correct | 5 ms | 456 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 248 ms | 1320 KB | Output is correct |
18 | Correct | 198 ms | 1008 KB | Output is correct |
19 | Correct | 52 ms | 560 KB | Output is correct |
20 | Correct | 14 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 728 KB | Output is correct |
2 | Correct | 4 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 2 ms | 504 KB | Output is correct |
5 | Correct | 2 ms | 404 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 98 ms | 1348 KB | Output is correct |
8 | Correct | 19 ms | 704 KB | Output is correct |
9 | Correct | 6 ms | 504 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 186 ms | 1356 KB | Output is correct |
13 | Correct | 140 ms | 1112 KB | Output is correct |
14 | Correct | 73 ms | 780 KB | Output is correct |
15 | Correct | 5 ms | 456 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 248 ms | 1320 KB | Output is correct |
18 | Correct | 198 ms | 1008 KB | Output is correct |
19 | Correct | 52 ms | 560 KB | Output is correct |
20 | Correct | 14 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Execution timed out | 1072 ms | 18660 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |