#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n,m,k;cin>>n>>m>>k;
vector<string> s(n);
for (auto &x:s)cin>>x;
string dir;cin>>dir;
vector<bitset<501>> bt(n);
for (int i=0;i<n;i++) {
for (int j=0;j<m;j++) {
if (s[i][j] == '#') {
bt[i][j] = 0;
}
else {
bt[i][j] = 1;
}
}
}
vector<bitset<501>> bt2 = bt, bt3 = bt;
for (auto x:dir) {
if (x == 'E' || x == '?') {
for (int i=0;i<n;i++) {
bt3[i] |= bt2[i] >> 1;
}
}
if (x == 'N' || x == '?') {
for (int i=1;i<n;i++) {
bt3[i-1] |= bt2[i];
}
}
if (x == 'W' || x == '?') {
for (int i=0;i<n;i++) {
bt3[i] |= bt2[i] << 1;
}
}
if (x == 'S' || x == '?') {
for (int i=1;i<n;i++) {
bt3[i] |= bt2[i-1];
}
}
for (int i=0;i<n;i++) {
bt3[i] &= bt[i];
}
swap(bt2, bt3);
for (auto &x:bt3) {
x.reset();
}
}
int res = 0;
for (auto x:bt2) {
res += x.count();
}
cout<<res<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |