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>
typedef long long int ll;
#define INF ll(1e9 + 7)
#define INF2 998244353
#define N (ll)(1e5 + 5)
using namespace std;
#define int ll
#define lsb(x) (x & (-x))
int r, c, m, g, h;
string s;
bitset<502> a[502], pos[502], t[502];
bitset<502> t1, t2;
int d1[] = {0, 0, 1, -1}, d2[] = {1, - 1, 0, 0};
void solve(){
cin >> r >> c >> m;
for(int i=1; i<=r; i++){
cin >> s;
for(int j=1; j<=c; j++){
a[i][j] = s[j - 1] == '.';
pos[i][j] = a[i][j];
}
}
cin >> s;
for(int i=0; i<m; i++){
if(s[i] == '?'){
for(int n=1; n<=r; n++){
t1 = a[n] >> 1;
t2 = a[n] << 1;
t[n] |= t1;
t[n] |= t2;
}
for(int n=1; n<r; n++){
t[n] |= a[n + 1];
t[n + 1] |= a[n];
}
for(int i=1; i<=r; i++){
a[i] = t[i] & pos[i];
t[i] &= 0;
}
}
else if(s[i] == 'W'){
for(int n=1; n<=r; n++){
a[n] = a[n] >> 1;
a[n] &= pos[n];
}
}
else if(s[i] == 'E'){
for(int n=1; n<=r; n++){
a[n] = a[n] << 1;
a[n] &= pos[n];
}
}
else if(s[i] == 'S'){
for(int n=r; n; n--){
a[n] |= a[n - 1];
a[n] &= a[n - 1];
a[n] &= pos[n];
}
}
else{
for(int n=1; n<=r; n++){
a[n] |= a[n + 1];
a[n] &= a[n + 1];
a[n] &= pos[n];
}
}
}
int sum = 0;
for(int n=r; n; n--){
for(int l=1; l<=c; l++){
sum += a[n][l];
}
}
cout << sum;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int T = 1;
//cin>>T;
while (T--){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |