# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
210043 | 2020-03-16T13:08:02 Z | AlainSu | ICC (CEOI16_icc) | C++14 | 0 ms | 0 KB |
#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; }