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;
const int N = 1505;
int n , m , t;
bitset<1500> row[N];
bitset<1500> dp[N] , d[N];
void J(char c){
if(c == 'N') for(int i= 1; i <= n; ++i) dp[i] = d[i + 1];
if(c == 'S') for(int i = 1; i <= n; ++i) dp[i] = d[i - 1];
if(c == 'E') for(int i= 1; i <= n; ++i) dp[i] = (d[i] << 1);
if(c == 'W') for(int i= 1; i <= n; ++i) dp[i] = (d[i] >> 1);
if(c == '?'){
for(int i= 1; i <= n; ++i){
dp[i] = d[i + 1];
dp[i] |= d[i - 1];
dp[i] |= (d[i]>>1);
dp[i] |= (d[i] << 1);
}
}
for(int i= 1; i <= n; ++i) dp[i] = dp[i] & row[i];
}
int main (){
cin >> n >> m >> t;
for(int i = 1; i <= n; ++i){
char ch;
for(int j = 0; j < m; ++j){
cin >> ch;
if(ch == '.') dp[i][j] = 1 , row[i][j] = 1;
else dp[i][j] = 0 , row[i][j] = 0;
}
}
//for(int i =1; i<= n; ++i) cout << row[i] <<endl;
string s;
cin >> s;
for(int i = 0; i< t; ++i){
for(int j =1; j <= n; ++j) d[j]=dp[j];
J(s[i]);
}
int ans = 0;
for(int i = 1; i <= n; ++i) ans += dp[i].count();
cout << ans;
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... |