# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
529660 | 2022-02-23T10:08:10 Z | c28dnv9q3 | Nautilus (BOI19_nautilus) | C++17 | 4 ms | 436 KB |
#include <stdio.h> char grid[505][505]; char path[5005]; bool dp[2][505][505]; int main() { int R, C, M; scanf("%d %d %d", &R, &C, &M); for(int r = 0; r < R; r++) { for(int c = 0; c < C; c++) { for(grid[r][c] = getchar(); grid[r][c] != '.' && grid[r][c] != '#'; grid[r][c] = getchar()); dp[0][r][c] = (grid[r][c] == '.'); } } for(int i = 0; i < M; i++) { for(path[i] = getchar(); path[i] != 'N' && path[i] != 'E' && path[i] != 'S' && path[i] != 'W' && path[i] != '?' ; path[i] = getchar()); } int g = 1, pg = 0; for(int i = M-1; i >= 0; i--) { char m = path[i]; for(int r = 0; r < R; r++) { for(int c = 0; c < C; c++) { dp[g][r][c] = false; if(grid[r][c] != '.') continue; if((m == '?' || m == 'N') && r < R-1) dp[g][r][c] |= dp[pg][r+1][c]; if((m == '?' || m == 'E') && c > 0) dp[g][r][c] |= dp[pg][r][c-1]; if((m == '?' || m == 'S') && r > 0) dp[g][r][c] |= dp[pg][r-1][c]; if((m == '?' || m == 'W') && c < C-1) dp[g][r][c] |= dp[pg][r][c+1]; // printf("[%d: %c] %d %d -> %d\n", i, m, r, c, dp[g][r][c]); } } pg = g; g = (g+1) % 2; } int pc = 0; for(int r = 0; r < R; r++) { for(int c = 0; c < C; c++) { if(grid[r][c] == '.' && dp[pg][r][c]) pc++; } } printf("%d\n", pc); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 332 KB | Output is correct |
2 | Incorrect | 4 ms | 436 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 332 KB | Output is correct |
2 | Incorrect | 4 ms | 436 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 332 KB | Output is correct |
2 | Incorrect | 4 ms | 436 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |