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;
const int N = 505;
using Val = bitset<N>;
Val org[N];
Val now[N];
Val nxt[N];
int main() {
ios_base::sync_with_stdio(false);
int n, m, k;
cin >> n >> m >> k;
vector<string> brd(n);
for (int i = 0; i < n; ++i) {
cin >> brd[i];
for (int j = 0; j < m; ++j) {
if (brd[i][j] == '.') {
org[i].set(j);
}
}
now[i] = org[i];
}
string mvs;
cin >> mvs;
for (char c : mvs) {
for (int i = 0; i < n; ++i) {
nxt[i] = {};
}
if (c == 'N' || c == '?') {
for (int i = 0; i + 1 < n; ++i) {
nxt[i] |= now[i + 1];
}
}
if (c == 'E' || c == '?') {
for (int i = 0; i < n; ++i) {
nxt[i] |= (now[i] << 1);
}
}
if (c == 'S' || c == '?') {
for (int i = 1; i < n; ++i) {
nxt[i] |= now[i - 1];
}
}
if (c == 'W' || c == '?') {
for (int i = 0; i < n; ++i) {
nxt[i] |= (now[i] >> 1);
}
}
for (int i = 0; i < n; ++i) {
now[i] = nxt[i] & org[i];
}
}
int ans = 0;
for (int i = 0; i < n; ++i) {
ans += now[i].count();
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |