Submission #131938

#TimeUsernameProblemLanguageResultExecution timeMemory
131938E869120Nautilus (BOI19_nautilus)C++14
100 / 100
216 ms772 KiB
#include <iostream> #include <string> #include <bitset> using namespace std; int H, W, N; string S; bitset<512> K[512], L[512], M[512], I; int main() { cin >> H >> W >> N; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { char c; cin >> c; if (c == '.') K[i].set(j); } L[i] = K[i]; } cin >> S; for (int i = 0; i < N; i++) { for (int j = 0; j < H; j++) M[j] = I; if (S[i] == 'E' || S[i] == '?') { for (int j = 0; j < H; j++) { M[j] |= (K[j] << 1); } } if (S[i] == 'W' || S[i] == '?') { for (int j = 0; j < H; j++) { M[j] |= (K[j] >> 1); } } if (S[i] == 'N' || S[i] == '?') { for (int j = 1; j < H; j++) { M[j - 1] |= K[j]; } } if (S[i] == 'S' || S[i] == '?') { for (int j = 0; j < H - 1; j++) { M[j + 1] |= K[j]; } } for (int j = 0; j < H; j++) { M[j] &= L[j]; } for (int j = 0; j < H; j++) K[j] = M[j]; } int cnt = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (K[i][j] == 1) cnt++; } } cout << cnt << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...