#include <bits/stdc++.h>
using namespace std;
int r,c,m;
char a[505][505];
string s;
//bool dp[105][105][105];
int main()
{
ios_base::sync_with_stdio(false);
cin>>r>>c>>m;
for(int i=0;i<r;i++) for(int j=0;j<c;j++) cin>>a[i][j];
cin>>s;
bitset<500> dp[m+10][r];
bitset<500> red[r];
for(int i=0;i<r;i++) for(int j=0;j<c;j++)
{
if(a[i][j]=='#')
{
dp[0][i][j]=0;
red[i][j]=0;
}
else
{
dp[0][i][j]=1;
red[i][j]=1;
}
}
for(int t=1;t<=m;t++)
{
char sad=s[t-1];
for(int i=0;i<r;i++)
{
if(sad=='W' || sad=='?') dp[t][i]|=(dp[t-1][i]>>1) & red[i];
if(sad=='E' || sad=='?') dp[t][i]|=(dp[t-1][i]<<1) & red[i];
if((sad=='S' || sad=='?') && i) dp[t][i]|=dp[t-1][i-1] & red[i];
if((sad=='N' || sad=='?') && i+1<r) dp[t][i]|=dp[t-1][i+1] & red[i];
/*else
{
}*/
}
}
int res=0;
for(int i=0;i<r;i++) res+=dp[m][i].count();
cout<<res<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1148 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1144 KB |
Output is correct |
4 |
Correct |
3 ms |
1144 KB |
Output is correct |
5 |
Correct |
3 ms |
1144 KB |
Output is correct |
6 |
Correct |
3 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1148 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1144 KB |
Output is correct |
4 |
Correct |
3 ms |
1144 KB |
Output is correct |
5 |
Correct |
3 ms |
1144 KB |
Output is correct |
6 |
Correct |
3 ms |
1144 KB |
Output is correct |
7 |
Correct |
3 ms |
1144 KB |
Output is correct |
8 |
Correct |
3 ms |
1144 KB |
Output is correct |
9 |
Correct |
4 ms |
1144 KB |
Output is correct |
10 |
Correct |
4 ms |
1144 KB |
Output is correct |
11 |
Correct |
3 ms |
1144 KB |
Output is correct |
12 |
Correct |
3 ms |
1016 KB |
Output is correct |
13 |
Correct |
3 ms |
1016 KB |
Output is correct |
14 |
Correct |
3 ms |
1144 KB |
Output is correct |
15 |
Correct |
3 ms |
1016 KB |
Output is correct |
16 |
Correct |
3 ms |
1020 KB |
Output is correct |
17 |
Correct |
3 ms |
1016 KB |
Output is correct |
18 |
Correct |
3 ms |
1016 KB |
Output is correct |
19 |
Correct |
4 ms |
1144 KB |
Output is correct |
20 |
Correct |
4 ms |
1020 KB |
Output is correct |
21 |
Correct |
4 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1148 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1144 KB |
Output is correct |
4 |
Correct |
3 ms |
1144 KB |
Output is correct |
5 |
Correct |
3 ms |
1144 KB |
Output is correct |
6 |
Correct |
3 ms |
1144 KB |
Output is correct |
7 |
Correct |
3 ms |
1144 KB |
Output is correct |
8 |
Correct |
3 ms |
1144 KB |
Output is correct |
9 |
Correct |
4 ms |
1144 KB |
Output is correct |
10 |
Correct |
4 ms |
1144 KB |
Output is correct |
11 |
Correct |
3 ms |
1144 KB |
Output is correct |
12 |
Correct |
3 ms |
1016 KB |
Output is correct |
13 |
Correct |
3 ms |
1016 KB |
Output is correct |
14 |
Correct |
3 ms |
1144 KB |
Output is correct |
15 |
Correct |
3 ms |
1016 KB |
Output is correct |
16 |
Correct |
3 ms |
1020 KB |
Output is correct |
17 |
Correct |
3 ms |
1016 KB |
Output is correct |
18 |
Correct |
3 ms |
1016 KB |
Output is correct |
19 |
Correct |
4 ms |
1144 KB |
Output is correct |
20 |
Correct |
4 ms |
1020 KB |
Output is correct |
21 |
Correct |
4 ms |
1144 KB |
Output is correct |
22 |
Correct |
233 ms |
157532 KB |
Output is correct |
23 |
Correct |
243 ms |
157916 KB |
Output is correct |
24 |
Correct |
234 ms |
157816 KB |
Output is correct |
25 |
Correct |
232 ms |
157704 KB |
Output is correct |
26 |
Correct |
234 ms |
157944 KB |
Output is correct |
27 |
Correct |
284 ms |
157892 KB |
Output is correct |
28 |
Correct |
288 ms |
157688 KB |
Output is correct |
29 |
Correct |
306 ms |
157944 KB |
Output is correct |
30 |
Correct |
296 ms |
157816 KB |
Output is correct |
31 |
Correct |
283 ms |
157688 KB |
Output is correct |
32 |
Correct |
330 ms |
157816 KB |
Output is correct |
33 |
Correct |
356 ms |
157860 KB |
Output is correct |
34 |
Correct |
330 ms |
157688 KB |
Output is correct |
35 |
Correct |
331 ms |
157816 KB |
Output is correct |
36 |
Correct |
336 ms |
157916 KB |
Output is correct |