///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define append push_back
#define add insert
#define nl "\n"
#define ff first
#define ss second
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define N 502
#define M 5001
char a[N][N];
bool dp[N][N][M];
void solve(){
char r;
int n,m,o,s;
cin>>n>>m>>o;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
dp[i][j][0]=(a[i][j]=='.');
}
}
s=0;
for(int k=1;k<=o;k++){
cin>>r;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='#') continue;
if(r=='?'){
if(dp[i+1][j][k-1]) dp[i][j][k]=1;
if(dp[i][j-1][k-1]) dp[i][j][k]=1;
if(dp[i-1][j][k-1]) dp[i][j][k]=1;
if(dp[i][j+1][k-1]) dp[i][j][k]=1;
}
if(r=='N' && dp[i+1][j][k-1])
dp[i][j][k]=1;
if(r=='E' && dp[i][j-1][k-1])
dp[i][j][k]=1;
if(r=='S' && dp[i-1][j][k-1])
dp[i][j][k]=1;
if(r=='W' && dp[i][j+1][k-1])
dp[i][j][k]=1;
if(dp[i][j][o]) s++;
}
}
}
cout<<s;
}
int main(){
L0TA;
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
244560 KB |
Output is correct |
2 |
Correct |
35 ms |
244624 KB |
Output is correct |
3 |
Correct |
30 ms |
244596 KB |
Output is correct |
4 |
Correct |
32 ms |
244572 KB |
Output is correct |
5 |
Correct |
27 ms |
244440 KB |
Output is correct |
6 |
Correct |
26 ms |
244568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
244560 KB |
Output is correct |
2 |
Correct |
35 ms |
244624 KB |
Output is correct |
3 |
Correct |
30 ms |
244596 KB |
Output is correct |
4 |
Correct |
32 ms |
244572 KB |
Output is correct |
5 |
Correct |
27 ms |
244440 KB |
Output is correct |
6 |
Correct |
26 ms |
244568 KB |
Output is correct |
7 |
Correct |
44 ms |
244560 KB |
Output is correct |
8 |
Correct |
36 ms |
244564 KB |
Output is correct |
9 |
Correct |
36 ms |
244572 KB |
Output is correct |
10 |
Correct |
28 ms |
244572 KB |
Output is correct |
11 |
Correct |
26 ms |
244456 KB |
Output is correct |
12 |
Correct |
30 ms |
244572 KB |
Output is correct |
13 |
Correct |
33 ms |
244552 KB |
Output is correct |
14 |
Correct |
37 ms |
244708 KB |
Output is correct |
15 |
Correct |
29 ms |
244652 KB |
Output is correct |
16 |
Correct |
25 ms |
244572 KB |
Output is correct |
17 |
Correct |
30 ms |
244700 KB |
Output is correct |
18 |
Correct |
35 ms |
244876 KB |
Output is correct |
19 |
Correct |
37 ms |
244572 KB |
Output is correct |
20 |
Correct |
31 ms |
244596 KB |
Output is correct |
21 |
Correct |
26 ms |
244604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
244560 KB |
Output is correct |
2 |
Correct |
35 ms |
244624 KB |
Output is correct |
3 |
Correct |
30 ms |
244596 KB |
Output is correct |
4 |
Correct |
32 ms |
244572 KB |
Output is correct |
5 |
Correct |
27 ms |
244440 KB |
Output is correct |
6 |
Correct |
26 ms |
244568 KB |
Output is correct |
7 |
Correct |
44 ms |
244560 KB |
Output is correct |
8 |
Correct |
36 ms |
244564 KB |
Output is correct |
9 |
Correct |
36 ms |
244572 KB |
Output is correct |
10 |
Correct |
28 ms |
244572 KB |
Output is correct |
11 |
Correct |
26 ms |
244456 KB |
Output is correct |
12 |
Correct |
30 ms |
244572 KB |
Output is correct |
13 |
Correct |
33 ms |
244552 KB |
Output is correct |
14 |
Correct |
37 ms |
244708 KB |
Output is correct |
15 |
Correct |
29 ms |
244652 KB |
Output is correct |
16 |
Correct |
25 ms |
244572 KB |
Output is correct |
17 |
Correct |
30 ms |
244700 KB |
Output is correct |
18 |
Correct |
35 ms |
244876 KB |
Output is correct |
19 |
Correct |
37 ms |
244572 KB |
Output is correct |
20 |
Correct |
31 ms |
244596 KB |
Output is correct |
21 |
Correct |
26 ms |
244604 KB |
Output is correct |
22 |
Runtime error |
35 ms |
262144 KB |
Execution killed with signal 9 |
23 |
Halted |
0 ms |
0 KB |
- |