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 <bits/stdc++.h>
using namespace std;
int main(){
int n, m, op; cin >> n >> m >> op; n += 2, m += 2; bitset<255000> dp, ok;
for (int i = 1; i < n - 1; i++)
for (int j = 1; j < m - 1; j++){
char c; cin >> c;
if (c == '.') dp[i * m + j] = ok[i * m + j] = 1;
}
for (int i = 0; i < op; i++){
char c; cin >> c;
if (c == 'N') dp >>= m;
if (c == 'S') dp <<= m;
if (c == 'W') dp >>= 1;
if (c == 'E') dp <<= 1;
if (c == '?') dp = (dp << m) | (dp >> m) | (dp << 1) | (dp >> 1);
dp &= ok;
}
cout<<dp.count()<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |