This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <bitset>
using namespace std;
const int MAXN = 500;
int n, m, q;
bitset<250505> valid, bs;
char sir[5003];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin >> n >> m >> q;
for (int i = 0; i < n; i++) {
cin >> sir;
for (int j = 0; j < m; j++) {
if (sir[j] == '.') {
valid.set(i*(m+1)+j);
}
}
}
cin >> sir;
bs = valid;
for (int i = 0; i < q; i++) {
if (sir[i] == 'N') {
bs >>= m+1;
}
else if (sir[i] == 'S') {
bs <<= m+1;
}
else if (sir[i] == 'W') {
bs >>= 1;
}
else if (sir[i] == 'E') {
bs <<= 1;
}
else {
bs = (bs >> (m+1)) | (bs << (m+1)) | (bs >> 1) | (bs << 1);
}
bs &= valid;
}
cout << bs.count();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |