#include <bits/stdc++.h>
using namespace std;
bitset<500> dp[2001][500], mat[500];
int main() {
int n, m, K, ans = 0;
cin >> n >> m >> K;
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
char ch; cin >> ch;
mat[i][j] = (ch == '.');
}
}
string s; cin >> s;
s = "." + s;
for(int i=0; i<n; i++)
for(int j=0; j<m; j++) dp[0][i][j] = mat[i][j];
for(int i=1; i<=K; i++) {
for(int r=0; r<n; r++) {
if(s[i] == 'W' || s[i] == '?') dp[i][r] |= (mat[r] & (dp[i-1][r] >> 1));
if(s[i] == 'E' || s[i] == '?') dp[i][r] |= (mat[r] & (dp[i-1][r] << 1));
if((s[i] == 'N' || s[i] == '?') && r + 1 < n) dp[i][r] |= (dp[i-1][r+1] & mat[r]);
if((s[i] == 'S' || s[i] == '?') && r - 1 >= 0) dp[i][r] |= (dp[i-1][r-1] & mat[r]);
}
}
for(int i=0; i<n; i++)
for(int j=0; j<m; j++) ans += dp[K][i][j];
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
3 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
2 ms |
4544 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
3 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
2 ms |
4544 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
2 ms |
4440 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4544 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
2 ms |
4444 KB |
Output is correct |
13 |
Correct |
2 ms |
4444 KB |
Output is correct |
14 |
Correct |
2 ms |
4444 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4440 KB |
Output is correct |
17 |
Correct |
2 ms |
4440 KB |
Output is correct |
18 |
Correct |
2 ms |
4444 KB |
Output is correct |
19 |
Correct |
2 ms |
4444 KB |
Output is correct |
20 |
Correct |
2 ms |
4548 KB |
Output is correct |
21 |
Correct |
2 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
3 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
2 ms |
4544 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
2 ms |
4440 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4544 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
2 ms |
4444 KB |
Output is correct |
13 |
Correct |
2 ms |
4444 KB |
Output is correct |
14 |
Correct |
2 ms |
4444 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4440 KB |
Output is correct |
17 |
Correct |
2 ms |
4440 KB |
Output is correct |
18 |
Correct |
2 ms |
4444 KB |
Output is correct |
19 |
Correct |
2 ms |
4444 KB |
Output is correct |
20 |
Correct |
2 ms |
4548 KB |
Output is correct |
21 |
Correct |
2 ms |
4444 KB |
Output is correct |
22 |
Runtime error |
116 ms |
127668 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |