#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
15 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
380 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
372 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
17 |
Correct |
4 ms |
380 KB |
Output is correct |
18 |
Correct |
4 ms |
376 KB |
Output is correct |
19 |
Correct |
4 ms |
376 KB |
Output is correct |
20 |
Correct |
4 ms |
376 KB |
Output is correct |
21 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
15 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
380 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
372 KB |
Output is correct |
16 |
Correct |
4 ms |
376 KB |
Output is correct |
17 |
Correct |
4 ms |
380 KB |
Output is correct |
18 |
Correct |
4 ms |
376 KB |
Output is correct |
19 |
Correct |
4 ms |
376 KB |
Output is correct |
20 |
Correct |
4 ms |
376 KB |
Output is correct |
21 |
Correct |
4 ms |
376 KB |
Output is correct |
22 |
Correct |
135 ms |
504 KB |
Output is correct |
23 |
Correct |
136 ms |
636 KB |
Output is correct |
24 |
Correct |
134 ms |
728 KB |
Output is correct |
25 |
Correct |
133 ms |
724 KB |
Output is correct |
26 |
Correct |
131 ms |
720 KB |
Output is correct |
27 |
Correct |
181 ms |
732 KB |
Output is correct |
28 |
Correct |
181 ms |
752 KB |
Output is correct |
29 |
Correct |
182 ms |
632 KB |
Output is correct |
30 |
Correct |
181 ms |
632 KB |
Output is correct |
31 |
Correct |
178 ms |
760 KB |
Output is correct |
32 |
Correct |
215 ms |
756 KB |
Output is correct |
33 |
Correct |
216 ms |
772 KB |
Output is correct |
34 |
Correct |
215 ms |
632 KB |
Output is correct |
35 |
Correct |
215 ms |
752 KB |
Output is correct |
36 |
Correct |
214 ms |
632 KB |
Output is correct |