#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1612 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1620 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |