#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int nmax = 5e5 + 1;
bitset <512> cur[505];
bitset <512> valid[505];
int main(){
int n, m, q; cin >> n >> m >> q;
char c[n + 1][m + 1];
for(int i = 1 ;i <= n; i++){
for(int j = 1 ;j <= m; j++)
cin >> c[i][j];
for(int j = 1 ;j <= m; j++){
if(c[i][j] == '.')
valid[i][j] = 1, cur[i][j] = 1;
}
}
for(int i = 1; i <= q; i++){
char c; cin >> c;
if(c == 'W'){
for(int j = 1; j <= n; j++)
cur[j] >>= 1,cur[j] &= valid[j];
}
if(c == 'E'){
for(int j = 1; j <= n; j++)
cur[j] <<= 1, cur[j] &= valid[j];
}
if(c == 'N'){
for(int j = 1; j <= n; j++){
cur[j] = cur[j + 1] & valid[j];
}
}
if(c == 'S'){
for(int j = n; j >= 1; j--)
cur[j] = cur[j - 1] & valid[j];
}
if(c == '?'){
bitset <512> x, y;
bitset <512> pr;
for(int j = 1; j <= n; j++){
x = (cur[j] >> 1);
y = (cur[j] << 1);
x |= y;
x |= pr;
x |= cur[j + 1];
pr = cur[j];
x &= valid[j];
cur[j] = x;
}
}
}
int ans = 0;
for(int j = 0; j <= n; j++)
for(int i = 1 ;i <= m; i++)
if(cur[j][i]) ans++;
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
316 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
312 KB |
Output is correct |
18 |
Correct |
2 ms |
308 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
2 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
316 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
312 KB |
Output is correct |
18 |
Correct |
2 ms |
308 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
2 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
85 ms |
832 KB |
Output is correct |
23 |
Correct |
82 ms |
832 KB |
Output is correct |
24 |
Correct |
76 ms |
852 KB |
Output is correct |
25 |
Correct |
78 ms |
832 KB |
Output is correct |
26 |
Correct |
79 ms |
824 KB |
Output is correct |
27 |
Correct |
118 ms |
828 KB |
Output is correct |
28 |
Correct |
121 ms |
928 KB |
Output is correct |
29 |
Correct |
122 ms |
784 KB |
Output is correct |
30 |
Correct |
118 ms |
724 KB |
Output is correct |
31 |
Correct |
119 ms |
824 KB |
Output is correct |
32 |
Correct |
151 ms |
724 KB |
Output is correct |
33 |
Correct |
151 ms |
832 KB |
Output is correct |
34 |
Correct |
162 ms |
852 KB |
Output is correct |
35 |
Correct |
156 ms |
832 KB |
Output is correct |
36 |
Correct |
196 ms |
844 KB |
Output is correct |