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;
using ll = long long;
const int mxN = 5e2 + 5, mod = 1e9 + 7, LOG = 20;
int r, c, m;
bool a[mxN][mxN];
bitset <mxN * mxN> A, B;
int main() {
ios :: sync_with_stdio(false), cin.tie(nullptr);
cin >> r >> c >> m;
for (int i = 1; i <= r; ++i) {
for (int j = 1; j <= c; ++j) {
char b;
cin >> b;
a[i][j] = (b == '.');
A[i * mxN + j] = B[i * mxN + j] = a[i][j];
}
}
string s;
cin >> s;
for (int i = 0; i < m; ++i) {
if (s[i] == 'S') A <<= mxN;
else if (s[i] == 'N') A >>= mxN;
else if (s[i] == 'W') A >>= 1;
else if (s[i] == 'E') A <<= 1;
else if (s[i] == '?') A = (A << mxN) | (A >> mxN) | (A >> 1) | (A << 1);
A &= B; // only water parts should be remained
}
cout << A.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... |