#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 9;
const int M = 5e3 + 9;
bitset <N> dp[N][M], good[N];
int main () {
int r, c, m;
cin >> r >> c >> m;
for (int i = 1; i <= r; i++) {
for (int j = c; j >= 1; j--) {
char x;
cin >> x;
dp[i][0][j] = good[i][j] = (x == '.');
}
}
string s;
cin >> s;
s = "#" + s;
for (int t = 1; t <= m; t++) {
for (int i = 1; i <= r; i++) {
if (s[t] == 'N')
dp[i][t] = dp[i + 1][t - 1] & good[i];
if (s[t] == 'W')
dp[i][t] = (dp[i][t - 1] << 1) & good[i];
if (s[t] == '?')
dp[i][t] = (dp[i + 1][t - 1] | dp[i - 1][t - 1] | (dp[i][t - 1] << 1) | (dp[i][t - 1] >> 1)) & good[i];
if (s[t] == 'S')
dp[i][t] = dp[i - 1][t - 1] & good[i];
if (s[t] == 'E')
dp[i][t] = (dp[i][t - 1] >> 1) & good[i];
}
}
int res = 0;
for (int i = 1; i <= r; i++)
res += dp[i][m].count();
cout << res << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
2 ms |
1356 KB |
Output is correct |
4 |
Correct |
2 ms |
1356 KB |
Output is correct |
5 |
Correct |
2 ms |
1356 KB |
Output is correct |
6 |
Correct |
2 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
2 ms |
1356 KB |
Output is correct |
4 |
Correct |
2 ms |
1356 KB |
Output is correct |
5 |
Correct |
2 ms |
1356 KB |
Output is correct |
6 |
Correct |
2 ms |
1356 KB |
Output is correct |
7 |
Correct |
2 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1284 KB |
Output is correct |
9 |
Correct |
2 ms |
1356 KB |
Output is correct |
10 |
Correct |
2 ms |
1328 KB |
Output is correct |
11 |
Correct |
2 ms |
1356 KB |
Output is correct |
12 |
Correct |
2 ms |
1356 KB |
Output is correct |
13 |
Correct |
2 ms |
1356 KB |
Output is correct |
14 |
Correct |
2 ms |
1356 KB |
Output is correct |
15 |
Correct |
2 ms |
1356 KB |
Output is correct |
16 |
Correct |
2 ms |
1384 KB |
Output is correct |
17 |
Correct |
2 ms |
1356 KB |
Output is correct |
18 |
Correct |
2 ms |
1356 KB |
Output is correct |
19 |
Correct |
2 ms |
1356 KB |
Output is correct |
20 |
Correct |
2 ms |
1356 KB |
Output is correct |
21 |
Correct |
2 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1356 KB |
Output is correct |
2 |
Correct |
1 ms |
1356 KB |
Output is correct |
3 |
Correct |
2 ms |
1356 KB |
Output is correct |
4 |
Correct |
2 ms |
1356 KB |
Output is correct |
5 |
Correct |
2 ms |
1356 KB |
Output is correct |
6 |
Correct |
2 ms |
1356 KB |
Output is correct |
7 |
Correct |
2 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1284 KB |
Output is correct |
9 |
Correct |
2 ms |
1356 KB |
Output is correct |
10 |
Correct |
2 ms |
1328 KB |
Output is correct |
11 |
Correct |
2 ms |
1356 KB |
Output is correct |
12 |
Correct |
2 ms |
1356 KB |
Output is correct |
13 |
Correct |
2 ms |
1356 KB |
Output is correct |
14 |
Correct |
2 ms |
1356 KB |
Output is correct |
15 |
Correct |
2 ms |
1356 KB |
Output is correct |
16 |
Correct |
2 ms |
1384 KB |
Output is correct |
17 |
Correct |
2 ms |
1356 KB |
Output is correct |
18 |
Correct |
2 ms |
1356 KB |
Output is correct |
19 |
Correct |
2 ms |
1356 KB |
Output is correct |
20 |
Correct |
2 ms |
1356 KB |
Output is correct |
21 |
Correct |
2 ms |
1356 KB |
Output is correct |
22 |
Correct |
156 ms |
157300 KB |
Output is correct |
23 |
Correct |
156 ms |
157380 KB |
Output is correct |
24 |
Correct |
161 ms |
157424 KB |
Output is correct |
25 |
Correct |
151 ms |
157324 KB |
Output is correct |
26 |
Correct |
193 ms |
157308 KB |
Output is correct |
27 |
Correct |
204 ms |
157416 KB |
Output is correct |
28 |
Correct |
216 ms |
157340 KB |
Output is correct |
29 |
Correct |
209 ms |
157300 KB |
Output is correct |
30 |
Correct |
208 ms |
157424 KB |
Output is correct |
31 |
Correct |
214 ms |
157368 KB |
Output is correct |
32 |
Correct |
250 ms |
157420 KB |
Output is correct |
33 |
Correct |
252 ms |
157324 KB |
Output is correct |
34 |
Correct |
280 ms |
157504 KB |
Output is correct |
35 |
Correct |
257 ms |
157352 KB |
Output is correct |
36 |
Correct |
271 ms |
157368 KB |
Output is correct |