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, k; cin >> n >> m>>k;
bitset<500> b[n], sea[n];
for (int i = 0; i < n; ++i) {
for (int j = m-1; j >= 0; --j) {
char c; cin >> c;
b[i][j] = sea[i][j] = (c=='.');
}
}
for (int i=0;i<k;++i){
char c; cin >> c;
bitset<500> nb[n];
if (c=='N') {
for (int j=0;j<n-1;++j){
nb[j] = b[j+1];
}
}
else if (c=='S') {
for (int j=1;j<n;++j){
nb[j] = b[j-1];
}
}
else if (c=='W') {
for (int j=0;j<n;++j){
nb[j] = b[j]<<1;
}
}
else if (c=='E') {
for (int j=0;j<n;++j){
nb[j] = b[j]>>1;
}
}
else {
for (int j=0;j<n;++j){
if (j) nb[j] |= b[j-1];
if (j<n-1) nb[j] |= b[j+1];
nb[j] |= ((b[j]<<1)|(b[j]>>1));
}
}
for (int j=0;j<n;++j){
nb[j] &= sea[j];
}
memcpy(b,nb,sizeof(nb));
}
int ans=0;
for (int i = 0; i<n; ++i){
ans += b[i].count();
}
cout << ans << endl;
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... |