#include <bits/stdc++.h>
using namespace std;
#define maxn 505
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
bitset<maxn> dp[maxn][2];
bitset<maxn> arr[maxn];
int n,m,len;
cin >> n >> m >> len;
string input;
char inp;
for(int i=1;i<=n;i++){
for(int j=1;i<=m;j++){
cin >> inp;
if(inp=='.'){
arr[i][j] = 1;
}
}
dp[i][0] = arr[i];
}
cin >> input;
for(int i=0;i<len;i++){
for(int a=1;a<=n;a++){
if(input.at(i)=='N'){
dp[a][(i+1)&1] = dp[a+1][i&1];
}
if(input.at(i)=='S'){
dp[a][(i+1)&1] = dp[a-1][i&1];
}
if(input.at(i)=='W'){
dp[a][(i+1)&1] = dp[a][i&1] >> 1;
}
if(input.at(i)=='E'){
dp[a][(i+1)&1] = dp[a][i&1] << 1;
}
if(input.at(i)=='?'){
dp[a][(i+1)&1] = (dp[a][i&1] << 1)|(dp[a][i&1] >> 1)|(dp[a-1][i&1])|(dp[a+1][i&1]);
}
dp[a][(i+1)&1] &= arr[a];
}
}
int ans = 0;
for(int i=1;i<=n;i++){
ans += dp[i][(input.length())&1].count();
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1076 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1076 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1076 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |