# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
529720 | 2022-02-23T14:23:37 Z | c28dnv9q3 | Nautilus (BOI19_nautilus) | C++17 | 1 ms | 332 KB |
#include <cstdio> #include <iostream> const int N_MAX = 512; const int M_MAX = 5005; int R, C, M; uint64_t map[4096]; uint64_t cur[2][4096]; void printcur(int k) { for (int i = 0; i <= R + 1; i++) { for (int j = 0; j <= C + 1; j++) { putchar((cur[k][i*8 + j/64] & (1ULL << (j%64))) ? '#' : '.'); } putchar('\n'); } putchar('\n'); } int main() { std::cin >> R >> C >> M; for (int i = 0; i < R; i++) { std::string s; std::cin >> s; for (int j = 0; j < C; j++) { if (s[j] == '.') { map[(i+1)*8 + (j+1)/64] |= 1ULL << ((j+1) % 64); } } } /*for (int i = 0; i < R + 2; i++) { map[i][0] = false; map[i][C+1] = false; } for (int j = 0; j < C + 2; j++) { map[0][j] = false; map[R+1][j] = false; }*/ int k = 0; for (int i = 0; i < 4096; i++) { cur[k][i] = map[i]; } // printf("Map at beginning\n"); // printcur(k); std::string instr; std::cin >> instr; for (int i = 0; i < instr.size(); i++) { char c = instr[i]; k = 1-k; // printf("INSTRUCTION %c (k=%d)\n", c, k); switch (c) { case 'N': for (int i = 8; i < 4096-8; i++) { cur[k][i] = cur[1-k][i+8] & map[i]; } break; case 'E': for (int i = 8; i < 4096-8; i++) { uint64_t main = cur[1-k][i] << 1ULL; uint64_t cp = cur[1-k][i+1] >> 63ULL; cur[k][i] = (main | cp) & map[i]; } break; case 'S': for (int i = 8; i < 4096-8; i++) { cur[k][i] = cur[1-k][i-8] & map[i]; } break; case 'W': for (int i = 8; i < 4096-8; i++) { uint64_t main = cur[1-k][i] >> 1ULL; uint64_t cp = cur[1-k][i-1] & 1ULL; cur[k][i] = (main | (cp << 63ULL)) & map[i]; } break; case '?': for (int i = 8; i < 4096-8; i++) { uint64_t m = 0; m |= cur[1-k][i+8]; m |= cur[1-k][i-8]; { uint64_t main = cur[1-k][i] >> 1ULL; uint64_t cp = cur[1-k][i-1] & 1ULL; m |= (main | (cp << 63ULL)); } { uint64_t main = cur[1-k][i] << 1ULL; uint64_t cp = (cur[1-k][i+1] >> 63ULL) & 1ULL; m |= main | cp; } cur[k][i] = m & map[i]; } break; } // printcur(k); } int num = 0; for (int i = 0; i < 4096; i++) { for (int j = 0; j < 64; j++) { num += (cur[k][i] & (1ULL << j)) ? 1 : 0; } } std::cout << num << std::endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |