#include <bits/stdc++.h>
using namespace std;
int main () {
int n, m, k; cin >> n >> m>>k;
bitset<9> 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<9> 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 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |