# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
807402 |
2023-08-04T16:51:06 Z |
MODDI |
Nautilus (BOI19_nautilus) |
C++14 |
|
1000 ms |
3284 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int r, c, n;
string str;
int mat[501][501];
int dp[2][501][501];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin>>r>>c>>n;
memset(dp, 0, sizeof dp);
memset(mat, 0, sizeof mat);
for(int i = 0; i < r; i++){
string s;
cin>>s;
for(int j = 0; j < c; j++){
if(s[j] == '.'){
mat[i][j] = 1;
dp[0][i][j] = 1;
}
}
}
cin>>str;
for(int step = 1; step <= n; step++){
int sega = step % 2, pret = (step-1) % 2;
for(int i = 0; i < r; i++){
for(int j = 0; j < c; j++){
dp[sega][i][j] = 0;
}
}
for(int i = 0; i < r; i++){
for(int j = 0; j < c; j++){
if(mat[i][j] == 1){
if((str[step-1] == 'E' || str[step-1] == '?') && dp[pret][i][j-1] == 1 && j > 0)
dp[sega][i][j] = 1;
if((str[step-1] == 'W' || str[step-1] == '?') && dp[pret][i][j+1] == 1 && j + 1 < c)
dp[sega][i][j] = 1;
if((str[step-1] == 'N' || str[step-1] == '?') && i < r-1 && dp[pret][i+1][j] == 1)
dp[sega][i][j] = 1;
if((str[step-1]=='S' || str[step-1] == '?') && i > 0 && dp[pret][i-1][j]==1)
dp[sega][i][j] = 1;
}
}
}
}
long long ans = 0;
int sega = n % 2;
for(int i = 0; i < r; i++){
for(int j = 0; j < c;j ++){
ans += dp[sega][i][j];
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3192 KB |
Output is correct |
2 |
Correct |
6 ms |
3156 KB |
Output is correct |
3 |
Correct |
7 ms |
3156 KB |
Output is correct |
4 |
Correct |
7 ms |
3156 KB |
Output is correct |
5 |
Correct |
4 ms |
3156 KB |
Output is correct |
6 |
Correct |
2 ms |
3156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3192 KB |
Output is correct |
2 |
Correct |
6 ms |
3156 KB |
Output is correct |
3 |
Correct |
7 ms |
3156 KB |
Output is correct |
4 |
Correct |
7 ms |
3156 KB |
Output is correct |
5 |
Correct |
4 ms |
3156 KB |
Output is correct |
6 |
Correct |
2 ms |
3156 KB |
Output is correct |
7 |
Correct |
6 ms |
3156 KB |
Output is correct |
8 |
Correct |
9 ms |
3272 KB |
Output is correct |
9 |
Correct |
7 ms |
3160 KB |
Output is correct |
10 |
Correct |
4 ms |
3156 KB |
Output is correct |
11 |
Correct |
2 ms |
3156 KB |
Output is correct |
12 |
Correct |
6 ms |
3156 KB |
Output is correct |
13 |
Correct |
10 ms |
3272 KB |
Output is correct |
14 |
Correct |
13 ms |
3272 KB |
Output is correct |
15 |
Correct |
6 ms |
3156 KB |
Output is correct |
16 |
Correct |
2 ms |
3156 KB |
Output is correct |
17 |
Correct |
6 ms |
3256 KB |
Output is correct |
18 |
Correct |
8 ms |
3156 KB |
Output is correct |
19 |
Correct |
9 ms |
3156 KB |
Output is correct |
20 |
Correct |
4 ms |
3156 KB |
Output is correct |
21 |
Correct |
2 ms |
3156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3192 KB |
Output is correct |
2 |
Correct |
6 ms |
3156 KB |
Output is correct |
3 |
Correct |
7 ms |
3156 KB |
Output is correct |
4 |
Correct |
7 ms |
3156 KB |
Output is correct |
5 |
Correct |
4 ms |
3156 KB |
Output is correct |
6 |
Correct |
2 ms |
3156 KB |
Output is correct |
7 |
Correct |
6 ms |
3156 KB |
Output is correct |
8 |
Correct |
9 ms |
3272 KB |
Output is correct |
9 |
Correct |
7 ms |
3160 KB |
Output is correct |
10 |
Correct |
4 ms |
3156 KB |
Output is correct |
11 |
Correct |
2 ms |
3156 KB |
Output is correct |
12 |
Correct |
6 ms |
3156 KB |
Output is correct |
13 |
Correct |
10 ms |
3272 KB |
Output is correct |
14 |
Correct |
13 ms |
3272 KB |
Output is correct |
15 |
Correct |
6 ms |
3156 KB |
Output is correct |
16 |
Correct |
2 ms |
3156 KB |
Output is correct |
17 |
Correct |
6 ms |
3256 KB |
Output is correct |
18 |
Correct |
8 ms |
3156 KB |
Output is correct |
19 |
Correct |
9 ms |
3156 KB |
Output is correct |
20 |
Correct |
4 ms |
3156 KB |
Output is correct |
21 |
Correct |
2 ms |
3156 KB |
Output is correct |
22 |
Execution timed out |
1063 ms |
3284 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |