#include <bits/stdc++.h>
using namespace std;
bitset<505> bs[2][505];
bitset<505> grid[505];
string s;
int R, C, L;
char x;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> R >> C >> L;
for (int i = 1; i <= R; ++i){
for (int j = 1; j <= C; ++j){
cin >> x;
if (x == '.'){
bs[0][i][j] = 1;
grid[i][j] = 1;
}
else grid[i][j] = bs[0][i][j] = 0;
}
}
cin >> s;
for (int a = 1; a <= L; ++a){
if (s[a-1] == 'W'){
for (int i = 1; i <= R; ++i){
bs[a&1][i] = (bs[(a-1)&1][i] >> 1) & (grid[i]);
}
}
if (s[a-1] == 'E'){
for (int i = 1; i <= R; ++i){
bs[a&1][i] = (bs[(a-1)&1][i] << 1) & (grid[i]);
}
}
if (s[a-1] == 'N'){
for (int i = 1; i <= R; ++i){
bs[a&1][i] = bs[(a-1)&1][i+1] & (grid[i]);
}
}
if (s[a-1] == 'S'){
for (int i = 1; i <= R; ++i){
bs[a&1][i] = bs[(a-1)&1][i-1] & (grid[i]);
}
}
if (s[a-1] == '?'){
for (int i = 1; i <= R; ++i){
bs[a&1][i] = (bs[(a-1)&1][i-1] | bs[(a-1)&1][i+1] | (bs[(a-1)&1][i] << 1) | (bs[(a-1)&1][i] >> 1)) & (grid[i]);
}
}
}
int sum = 0;
for (int i = 1; i <= R; ++i){
for (int j = 1; j <= C; ++j){
if (!grid[i][j]) continue;
sum += bs[L&1][i][j];
}
}
cout << sum << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
6 ms |
376 KB |
Output is correct |
16 |
Correct |
6 ms |
376 KB |
Output is correct |
17 |
Correct |
6 ms |
504 KB |
Output is correct |
18 |
Correct |
6 ms |
380 KB |
Output is correct |
19 |
Correct |
6 ms |
376 KB |
Output is correct |
20 |
Correct |
6 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
6 ms |
376 KB |
Output is correct |
16 |
Correct |
6 ms |
376 KB |
Output is correct |
17 |
Correct |
6 ms |
504 KB |
Output is correct |
18 |
Correct |
6 ms |
380 KB |
Output is correct |
19 |
Correct |
6 ms |
376 KB |
Output is correct |
20 |
Correct |
6 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
376 KB |
Output is correct |
22 |
Correct |
107 ms |
740 KB |
Output is correct |
23 |
Correct |
107 ms |
632 KB |
Output is correct |
24 |
Correct |
103 ms |
632 KB |
Output is correct |
25 |
Correct |
103 ms |
740 KB |
Output is correct |
26 |
Correct |
101 ms |
740 KB |
Output is correct |
27 |
Correct |
165 ms |
632 KB |
Output is correct |
28 |
Correct |
171 ms |
632 KB |
Output is correct |
29 |
Correct |
170 ms |
760 KB |
Output is correct |
30 |
Correct |
176 ms |
632 KB |
Output is correct |
31 |
Correct |
171 ms |
632 KB |
Output is correct |
32 |
Correct |
220 ms |
764 KB |
Output is correct |
33 |
Correct |
217 ms |
632 KB |
Output is correct |
34 |
Correct |
225 ms |
652 KB |
Output is correct |
35 |
Correct |
221 ms |
888 KB |
Output is correct |
36 |
Correct |
216 ms |
632 KB |
Output is correct |