#include <bits/stdc++.h>
#define ll long long
using namespace std;
char a[105][105];
int dp[105][105][105];
int main(){
int r,c,m;
cin>>r>>c>>m;
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
cin>>a[i][j];
}
}
int say=0;
string s;
cin>>s;
for (int i=1;i<=r;i++) {
for (int j=1;j<=c;j++) {
dp[i][j][0]=(a[i][j]=='.');
}
}
for(int k=1;k<=m;k++) {
for(int i=1; i<=r;i++) {
for(int j=1; j<=c;j++) {
if (a[i][j] == '#')
continue;
int x = i, y = j;
if (s[k-1]=='N')x++;
else if(s[k-1]=='S')x--;
else if(s[k-1]=='W')y++;
else if(s[k-1]=='E')y--;
else{
x--;
dp[i][j][k] |= dp[i - 1][j][k-1];
dp[i][j][k] |= dp[i][j - 1][k-1];
dp[i][j][k] |= dp[i + 1][j][k-1];
dp[i][j][k] |= dp[i][j + 1][k-1];
}
dp[i][j][k] |= dp[x][y][k-1];
}
}
}
for(int i=1;i<=r;i++) {
for(int j=1;j<=c;j++) {
say += dp[i][j][m];
}
}
cout<<say;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
4556 KB |
Output is correct |
2 |
Correct |
10 ms |
4556 KB |
Output is correct |
3 |
Correct |
9 ms |
4556 KB |
Output is correct |
4 |
Correct |
8 ms |
4636 KB |
Output is correct |
5 |
Correct |
8 ms |
4608 KB |
Output is correct |
6 |
Correct |
4 ms |
4532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
4556 KB |
Output is correct |
2 |
Correct |
10 ms |
4556 KB |
Output is correct |
3 |
Correct |
9 ms |
4556 KB |
Output is correct |
4 |
Correct |
8 ms |
4636 KB |
Output is correct |
5 |
Correct |
8 ms |
4608 KB |
Output is correct |
6 |
Correct |
4 ms |
4532 KB |
Output is correct |
7 |
Correct |
8 ms |
4632 KB |
Output is correct |
8 |
Correct |
9 ms |
4556 KB |
Output is correct |
9 |
Correct |
9 ms |
4640 KB |
Output is correct |
10 |
Correct |
7 ms |
4528 KB |
Output is correct |
11 |
Correct |
4 ms |
4556 KB |
Output is correct |
12 |
Correct |
8 ms |
4556 KB |
Output is correct |
13 |
Correct |
9 ms |
4632 KB |
Output is correct |
14 |
Correct |
9 ms |
4556 KB |
Output is correct |
15 |
Correct |
7 ms |
4556 KB |
Output is correct |
16 |
Correct |
4 ms |
4556 KB |
Output is correct |
17 |
Correct |
10 ms |
4556 KB |
Output is correct |
18 |
Correct |
10 ms |
4632 KB |
Output is correct |
19 |
Correct |
14 ms |
4556 KB |
Output is correct |
20 |
Correct |
6 ms |
4556 KB |
Output is correct |
21 |
Correct |
4 ms |
4556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
4556 KB |
Output is correct |
2 |
Correct |
10 ms |
4556 KB |
Output is correct |
3 |
Correct |
9 ms |
4556 KB |
Output is correct |
4 |
Correct |
8 ms |
4636 KB |
Output is correct |
5 |
Correct |
8 ms |
4608 KB |
Output is correct |
6 |
Correct |
4 ms |
4532 KB |
Output is correct |
7 |
Correct |
8 ms |
4632 KB |
Output is correct |
8 |
Correct |
9 ms |
4556 KB |
Output is correct |
9 |
Correct |
9 ms |
4640 KB |
Output is correct |
10 |
Correct |
7 ms |
4528 KB |
Output is correct |
11 |
Correct |
4 ms |
4556 KB |
Output is correct |
12 |
Correct |
8 ms |
4556 KB |
Output is correct |
13 |
Correct |
9 ms |
4632 KB |
Output is correct |
14 |
Correct |
9 ms |
4556 KB |
Output is correct |
15 |
Correct |
7 ms |
4556 KB |
Output is correct |
16 |
Correct |
4 ms |
4556 KB |
Output is correct |
17 |
Correct |
10 ms |
4556 KB |
Output is correct |
18 |
Correct |
10 ms |
4632 KB |
Output is correct |
19 |
Correct |
14 ms |
4556 KB |
Output is correct |
20 |
Correct |
6 ms |
4556 KB |
Output is correct |
21 |
Correct |
4 ms |
4556 KB |
Output is correct |
22 |
Runtime error |
5 ms |
588 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |