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, q;
cin >> n >> m >> q;
vector<bitset<502>> mat(n + 2), templ, temp;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
char ch;
cin >> ch;
mat[i][j] = (ch == '.'? 1 : 0);
}
}
templ = mat;
for(int tc = 0; tc < q; tc++) {
char ch;
cin >> ch;
if(ch == 'W') {
for(int i = 1; i <= n; i++)
mat[i] = (mat[i] & (mat[i] << 1));
}
if(ch == 'E') {
for(int i = 1; i <= n; i++)
mat[i] = (mat[i] & (mat[i] >> 1));
}
if(ch == 'N') {
for(int i = n; i >= 0; i--) {
mat[i] &= mat[i - 1];
}
mat[0].reset();
}
if(ch == 'N') {
for(int i = 1; i < n; i++) {
mat[i] &= mat[i + 1];
}
mat[n].reset();
}
if(ch == '?') {
temp = mat;
for(int i = 1; i <= n; i++)
mat[i] = (mat[i] | (mat[i] >> 1) | (mat[i] << 1) | temp[i - 1] | temp[i + 1]) & templ[i];
}
}
int total = 0;
for(int i = 0; i < n; i++) {
total += mat[i].count();
}
cout << total << '\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... |