#include <bits/stdc++.h>
using namespace std;
int main () {
int n, m, k; cin >> n >> m>>k;
bitset<500> b[n], sea[n];
for (int i = 0; i < n; ++i) {
for (int j = m-1; j >= 0; --j) {
char c; cin >> c;
b[i][j] = sea[i][j] = (c=='.');
}
}
for (int i=0;i<k;++i){
char c; cin >> c;
bitset<500> nb[n];
if (c=='N') {
for (int j=0;j<n-1;++j){
nb[j] = b[j+1];
}
}
else if (c=='S') {
for (int j=1;j<n;++j){
nb[j] = b[j-1];
}
}
else if (c=='W') {
for (int j=0;j<n;++j){
nb[j] = b[j]<<1;
}
}
else if (c=='E') {
for (int j=0;j<n;++j){
nb[j] = b[j]>>1;
}
}
else {
for (int j=0;j<n;++j){
if (j) nb[j] |= b[j-1];
if (j<n-1) nb[j] |= b[j+1];
nb[j] |= ((b[j]<<1)|(b[j]>>1));
}
}
for (int j=0;j<n;++j){
nb[j] &= sea[j];
}
memcpy(b,nb,sizeof(nb));
}
int ans=0;
for (int i = 0; i<n; ++i){
ans += b[i].count();
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
312 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
304 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 |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
2 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
308 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
312 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
304 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 |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
2 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
308 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
72 ms |
600 KB |
Output is correct |
23 |
Correct |
89 ms |
716 KB |
Output is correct |
24 |
Correct |
82 ms |
616 KB |
Output is correct |
25 |
Correct |
71 ms |
596 KB |
Output is correct |
26 |
Correct |
74 ms |
616 KB |
Output is correct |
27 |
Correct |
103 ms |
620 KB |
Output is correct |
28 |
Correct |
132 ms |
616 KB |
Output is correct |
29 |
Correct |
102 ms |
620 KB |
Output is correct |
30 |
Correct |
101 ms |
632 KB |
Output is correct |
31 |
Correct |
103 ms |
616 KB |
Output is correct |
32 |
Correct |
133 ms |
620 KB |
Output is correct |
33 |
Correct |
120 ms |
616 KB |
Output is correct |
34 |
Correct |
126 ms |
620 KB |
Output is correct |
35 |
Correct |
171 ms |
592 KB |
Output is correct |
36 |
Correct |
133 ms |
620 KB |
Output is correct |