# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
723460 | 2023-04-13T20:41:15 Z | lovrot | Nautilus (BOI19_nautilus) | C++17 | 1000 ms | 1200 KB |
#include <cstdio> #include <cstring> #pragma GCC optimize("Ofast") using namespace std; const int N = 510; const int lx[4] = {1, -1, 0, 0}; const int ly[4] = {0, 0, -1, 1}; int n, m, q; bool dp[2][N][N], mat[N][N]; int main() { scanf("%d%d%d", &n, &m, &q); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) { char c; scanf(" %c", &c); dp[0][i][j] = c == '.'; mat[i][j] = !dp[0][i][j]; } bool flag = 1; for(int t = 0; t < q; t++) { char c; scanf(" %c", &c); // printf("%c\n", c); int x = -1; if(c == 'S') x = 1; if(c == 'N') x = 0; if(c == 'W') x = 3; if(c == 'E') x = 2; if(x == -1) { memset(dp[flag], 0, sizeof(dp[flag])); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) for(int k = 0; k < 4; k++) dp[flag][i][j] |= !mat[i][j] && dp[!flag][i + lx[k]][j + ly[k]]; } else { for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) dp[flag][i][j] = !mat[i][j] && dp[!flag][i + lx[x]][j + ly[x]]; } flag ^= 1; } int sol = 0; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) sol += dp[!flag][i][j]; printf("%d\n", sol); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 3 ms | 424 KB | Output is correct |
3 | Correct | 4 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 452 KB | Output is correct |
5 | Correct | 3 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 3 ms | 424 KB | Output is correct |
3 | Correct | 4 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 452 KB | Output is correct |
5 | Correct | 3 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 3 ms | 852 KB | Output is correct |
8 | Correct | 7 ms | 852 KB | Output is correct |
9 | Correct | 6 ms | 852 KB | Output is correct |
10 | Correct | 4 ms | 852 KB | Output is correct |
11 | Correct | 2 ms | 852 KB | Output is correct |
12 | Correct | 3 ms | 852 KB | Output is correct |
13 | Correct | 8 ms | 812 KB | Output is correct |
14 | Correct | 10 ms | 860 KB | Output is correct |
15 | Correct | 5 ms | 852 KB | Output is correct |
16 | Correct | 2 ms | 812 KB | Output is correct |
17 | Correct | 4 ms | 852 KB | Output is correct |
18 | Correct | 7 ms | 812 KB | Output is correct |
19 | Correct | 7 ms | 852 KB | Output is correct |
20 | Correct | 5 ms | 808 KB | Output is correct |
21 | Correct | 3 ms | 808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 3 ms | 424 KB | Output is correct |
3 | Correct | 4 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 452 KB | Output is correct |
5 | Correct | 3 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Correct | 3 ms | 852 KB | Output is correct |
8 | Correct | 7 ms | 852 KB | Output is correct |
9 | Correct | 6 ms | 852 KB | Output is correct |
10 | Correct | 4 ms | 852 KB | Output is correct |
11 | Correct | 2 ms | 852 KB | Output is correct |
12 | Correct | 3 ms | 852 KB | Output is correct |
13 | Correct | 8 ms | 812 KB | Output is correct |
14 | Correct | 10 ms | 860 KB | Output is correct |
15 | Correct | 5 ms | 852 KB | Output is correct |
16 | Correct | 2 ms | 812 KB | Output is correct |
17 | Correct | 4 ms | 852 KB | Output is correct |
18 | Correct | 7 ms | 812 KB | Output is correct |
19 | Correct | 7 ms | 852 KB | Output is correct |
20 | Correct | 5 ms | 808 KB | Output is correct |
21 | Correct | 3 ms | 808 KB | Output is correct |
22 | Execution timed out | 1077 ms | 1200 KB | Time limit exceeded |
23 | Halted | 0 ms | 0 KB | - |