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;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
const int N = 501;
char c[N][N];
bitset<10> dp[N], ndp[N], ok[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k;
cin >> n >> m >> k;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> c[i][j];
ok[i][j] = (c[i][j] == '.');
}
//deb(ok[i]) cout << '\n';
}
cout << '\n';
string s;
cin >> s;
for (int i = 1; i <= n; ++i) {
dp[i] = ok[i];
}
for (int p = 0; p < k; ++p) {
for (int i = 1; i <= n; ++i) {
if (s[p] == 'W') {
deb(dp[i]) cout << '\n';
ndp[i] |= dp[i] >> 1;
} else if (s[p] == 'E') {
ndp[i] |= dp[i] << 1;
} else if (s[p] == 'N') {
ndp[i - 1] |= dp[i];
} else if (s[p] == 'S') {
ndp[i + 1] |= dp[i];
} else {
ndp[i] |= (dp[i] >> 1) | (dp[i] << 1);
ndp[i - 1] |= dp[i];
ndp[i + 1] |= dp[i];
}
}
for (int i = 1; i <= n; ++i) {
ndp[i] &= ok[i];
dp[i] = ndp[i];
ndp[i].reset();
}
}
int ans = 0;
for (int i = 1; i <= n; ++i) {
ans += dp[i].count();
}
cout << ans << '\n';
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... |