#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, q;
cin >> n >> m >> q;
vector<bitset<502>> mat(n + 2), templ, temp;
for(int i = 1; i <= n; i++) {
for(int j = m; j > 0; j--) {
char ch;
cin >> ch;
mat[i][j] = (ch == '.'? 1 : 0);
//cout << ch << " \n"[j == 1];
}
}
templ = mat;
for(int tc = 0; tc < q; tc++) {
char ch;
cin >> ch;
if(ch == 'W') {
for(int i = 1; i <= n; i++)
mat[i] = (templ[i] & (mat[i] << 1));
}
if(ch == 'E') {
for(int i = 1; i <= n; i++)
mat[i] = (templ[i] & (mat[i] >> 1));
}
if(ch == 'N') {
for(int i = 1; i <= n; i++) {
mat[i] = mat[i + 1] & templ[i];
}
}
if(ch == 'S') {
for(int i = n; i > 0; i--) {
mat[i] = mat[i - 1] & templ[i];
}
}
if(ch == '?') {
temp = mat;
for(int i = 1; i <= n; i++)
mat[i] = ((mat[i] >> 1) | (mat[i] << 1) | temp[i - 1] | temp[i + 1]) & templ[i];
}
//for(int i = 1; i <= n; i++) {
//cerr << mat[i] << '\n';
//}
//cerr << '\n';
}
int total = 0;
for(int i = 1; i <= n; i++) {
total += mat[i].count();
}
cout << total << '\n';
}
# |
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 |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 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 |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
316 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
308 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
308 KB |
Output is correct |
18 |
Correct |
2 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
312 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 |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
316 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
308 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
308 KB |
Output is correct |
18 |
Correct |
2 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
312 KB |
Output is correct |
20 |
Correct |
2 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
103 ms |
632 KB |
Output is correct |
23 |
Correct |
110 ms |
628 KB |
Output is correct |
24 |
Correct |
106 ms |
628 KB |
Output is correct |
25 |
Correct |
104 ms |
624 KB |
Output is correct |
26 |
Correct |
101 ms |
596 KB |
Output is correct |
27 |
Correct |
154 ms |
596 KB |
Output is correct |
28 |
Correct |
151 ms |
624 KB |
Output is correct |
29 |
Correct |
151 ms |
576 KB |
Output is correct |
30 |
Correct |
153 ms |
624 KB |
Output is correct |
31 |
Correct |
148 ms |
580 KB |
Output is correct |
32 |
Correct |
185 ms |
596 KB |
Output is correct |
33 |
Correct |
189 ms |
624 KB |
Output is correct |
34 |
Correct |
188 ms |
628 KB |
Output is correct |
35 |
Correct |
192 ms |
632 KB |
Output is correct |
36 |
Correct |
190 ms |
632 KB |
Output is correct |