#include<bits/stdc++.h>
using namespace std;
bitset<512> tmp[502],grd[502],pos[502];
int main() {
int r, c, m;
cin >> r >> c >> m;
for(int i = 1; i <= r; i++) {
for(int j = 1; j <= c; j++) {
char c = getchar();
if(j==1)
c=getchar();
grd[i][j]=(c=='.');
}
pos[i]=grd[i];
}
for(int i = 0; i < m; i++) {
char c = getchar();
if(!i) c=getchar();
for(int j = 1; j <= r; j++)
tmp[j]=pos[j], pos[j].reset();
for(int j = 1; j <= r; j++) {
if(c=='N'||c=='?')
pos[j]|=tmp[j+1];
if(c=='S'||c=='?')
pos[j]|=tmp[j-1];
if(c=='E'||c=='?')
pos[j]|=tmp[j]<<1;
if(c=='W'||c=='?')
pos[j]|=tmp[j]>>1;
pos[j]&=grd[j];
}
}
int ans = 0;
for(int i = 1; i <= r; i++)
ans+=pos[i].count();
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
504 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
504 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
65 ms |
500 KB |
Output is correct |
23 |
Correct |
65 ms |
348 KB |
Output is correct |
24 |
Correct |
64 ms |
348 KB |
Output is correct |
25 |
Correct |
64 ms |
508 KB |
Output is correct |
26 |
Correct |
63 ms |
348 KB |
Output is correct |
27 |
Correct |
89 ms |
600 KB |
Output is correct |
28 |
Correct |
92 ms |
348 KB |
Output is correct |
29 |
Correct |
93 ms |
348 KB |
Output is correct |
30 |
Correct |
91 ms |
504 KB |
Output is correct |
31 |
Correct |
89 ms |
344 KB |
Output is correct |
32 |
Correct |
111 ms |
344 KB |
Output is correct |
33 |
Correct |
110 ms |
344 KB |
Output is correct |
34 |
Correct |
111 ms |
348 KB |
Output is correct |
35 |
Correct |
110 ms |
344 KB |
Output is correct |
36 |
Correct |
110 ms |
504 KB |
Output is correct |