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;
#define int int64_t
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n,m,k;cin>>n>>m>>k;
vector<string> s(n);
for (auto &x:s)cin>>x;
string dir;cin>>dir;
vector<bitset<501>> bt(n);
for (int i=0;i<n;i++) {
for (int j=0;j<m;j++) {
if (s[i][j] == '#') {
bt[i][j] = 0;
}
else {
bt[i][j] = 1;
}
}
}
vector<bitset<501>> bt2 = bt, bt3(n);
for (auto x:dir) {
if (x == 'E' || x == '?') {
for (int i=0;i<n;i++) {
bt3[i] |= bt2[i] << 1;
}
}
if (x == 'N' || x == '?') {
for (int i=1;i<n;i++) {
bt3[i-1] |= bt2[i];
}
}
if (x == 'W' || x == '?') {
for (int i=0;i<n;i++) {
bt3[i] |= bt2[i] >> 1;
}
}
if (x == 'S' || x == '?') {
for (int i=1;i<n;i++) {
bt3[i] |= bt2[i-1];
}
}
for (int i=0;i<n;i++) {
bt3[i] &= bt[i];
}
swap(bt2, bt3);
for (auto &x:bt3) {
x.reset();
}
}
int res = 0;
for (auto x:bt2) {
res += x.count();
}
cout<<res<<"\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... |