#include <bits/stdc++.h>
#define DEBUG 0
using namespace std;
const int MAX_N = 5e2 + 10;
char S[MAX_N][MAX_N];
bitset <MAX_N> dp[MAX_N], tmp[MAX_N], original[MAX_N];
int main() {
cin.tie(0)->sync_with_stdio(0);
int R, C, M;
cin >> R >> C >> M;
for(int i = 1; i <= R; i++) {
cin >> (S[i] + 1);
}
for(int i = 1; i <= R; i++) {
for(int j = 1; j <= C; j++) {
if(S[i][j] == '.') {
original[i][j] = 1;
}
}
}
string d;
cin >> d;
for(int i = 1; i <= R; i++) {
dp[i] = original[i];
}
for(auto v : d) {
for(int i = 1; i <= R; i++) {
tmp[i] = 0;
}
if(v == 'N' or v == '?') {
for(int i = 1; i < R; i++) {
tmp[i] |= dp[i + 1];
}
}
if(v == 'E' or v == '?') {
for(int i = 1; i <= R; i++) {
tmp[i] |= (dp[i]<<1);
}
}
if(v == 'S' or v == '?') {
for(int i = 2; i <= R; i++) {
tmp[i] |= dp[i - 1];
}
}
if(v == 'W' or v == '?') {
for(int i = 1; i <= R; i++) {
tmp[i] |= (dp[i]>>1);
}
}
for(int i = 1; i <= R; i++) {
dp[i] = (tmp[i] & original[i]);
}
}
int ans = 0;
for(int i = 1; i <= R; i++) {
ans += dp[i].count();
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
3 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
3 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
183 ms |
916 KB |
Output is correct |
23 |
Correct |
194 ms |
920 KB |
Output is correct |
24 |
Correct |
195 ms |
920 KB |
Output is correct |
25 |
Correct |
186 ms |
920 KB |
Output is correct |
26 |
Correct |
181 ms |
896 KB |
Output is correct |
27 |
Correct |
239 ms |
852 KB |
Output is correct |
28 |
Correct |
215 ms |
916 KB |
Output is correct |
29 |
Correct |
224 ms |
924 KB |
Output is correct |
30 |
Correct |
260 ms |
920 KB |
Output is correct |
31 |
Correct |
212 ms |
900 KB |
Output is correct |
32 |
Correct |
271 ms |
916 KB |
Output is correct |
33 |
Correct |
260 ms |
916 KB |
Output is correct |
34 |
Correct |
266 ms |
920 KB |
Output is correct |
35 |
Correct |
272 ms |
924 KB |
Output is correct |
36 |
Correct |
252 ms |
896 KB |
Output is correct |