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 N 505
int r, c, m;
string s;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> r >> c >> m;
// bitset<5> tes;
// tes.set(3);
// cout << tes << " W :" << (tes >> 1) << " E:" << (tes << 1) << "\n";
vector<bitset<N>> base(N), thispos(N);
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
char typ;
cin >> typ;
if (typ == '#') continue;
base[i].set(j);
}
}
thispos = base;
cin >> s;
s = " " + s;
for (int i = 1; i <= m; i++){
vector<bitset<N>> tmp(N);
if (s[i] == '?' || s[i] == 'N'){
for (int j = 1; j < r; j++){
tmp[j] = thispos[j + 1];
}
}
if (s[i] == '?' || s[i] == 'E'){
for (int j = 1; j <= r; j++){
tmp[j] |= (thispos[j] << 1);
}
}
if (s[i] == '?' || s[i] == 'S'){
for (int j = 2; j <= r; j++){
tmp[j] |= thispos[j - 1];
}
}
if (s[i] == '?' || s[i] == 'W'){
for (int j = 1; j <= r; j++){
tmp[j] |= (thispos[j] >> 1);
}
}
for (int j = 1; j <= r; j++) thispos[j] = (tmp[j] & base[j]);
}
int res = 0;
for (int i = 1; i <= r; i++) res += thispos[i].count();
cout << res;
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... |