# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
919933 |
2024-02-01T21:22:19 Z |
Alebn |
Nautilus (BOI19_nautilus) |
C++14 |
|
269 ms |
262144 KB |
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int n, m, len;
string s;
bool check(int i, int j) {
if(i > -1 && j > -1 && i < n && j < m) return true;
return false;
}
int main() {
cin >> n >> m >> len;
vector<string> a(n);
for(int i = 0; i < n; i++) cin >> a[i];
cin >> s;
//dp
vector<vector<vector<bool>>> dp(len+1, vector<vector<bool>>(n, vector<bool>(m)));
//base case
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) dp[0][i][j] = (a[i][j] == '.');
}
//transition
vector<pair<int,int>> dirs = {
{-1, 0},
{0, 1},
{1, 0},
{0, -1}
};
map<char,int> mp = {
{'N', 0},
{'E', 1},
{'S', 2},
{'W', 3}
};
pair<int,int> dir;
for(int k = 1; k <= len; k++) {
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(a[i][j] == '#') continue;
if(s[k-1] == '?') {
for(auto dir : dirs) {
if(check(i+dir.first, j+dir.second) && dp[k-1][i+dir.first][j+dir.second]) dp[k][i][j] = 1;
}
}
else {
dir = dirs[(mp[s[k-1]]+2)%4];
if(check(i+dir.first, j+dir.second) && dp[k-1][i+dir.first][j+dir.second]) dp[k][i][j] = 1;
}
}
}
}
//final state
int res = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) res += dp[len][i][j];
}
cout << res << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1112 KB |
Output is correct |
2 |
Correct |
8 ms |
1368 KB |
Output is correct |
3 |
Correct |
9 ms |
1112 KB |
Output is correct |
4 |
Correct |
9 ms |
1116 KB |
Output is correct |
5 |
Correct |
5 ms |
1112 KB |
Output is correct |
6 |
Correct |
2 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1112 KB |
Output is correct |
2 |
Correct |
8 ms |
1368 KB |
Output is correct |
3 |
Correct |
9 ms |
1112 KB |
Output is correct |
4 |
Correct |
9 ms |
1116 KB |
Output is correct |
5 |
Correct |
5 ms |
1112 KB |
Output is correct |
6 |
Correct |
2 ms |
1112 KB |
Output is correct |
7 |
Correct |
9 ms |
1368 KB |
Output is correct |
8 |
Correct |
12 ms |
1112 KB |
Output is correct |
9 |
Correct |
10 ms |
1116 KB |
Output is correct |
10 |
Correct |
6 ms |
1116 KB |
Output is correct |
11 |
Correct |
3 ms |
1112 KB |
Output is correct |
12 |
Correct |
11 ms |
1112 KB |
Output is correct |
13 |
Correct |
16 ms |
1116 KB |
Output is correct |
14 |
Correct |
17 ms |
1112 KB |
Output is correct |
15 |
Correct |
6 ms |
1112 KB |
Output is correct |
16 |
Correct |
2 ms |
1112 KB |
Output is correct |
17 |
Correct |
12 ms |
1112 KB |
Output is correct |
18 |
Correct |
16 ms |
1112 KB |
Output is correct |
19 |
Correct |
14 ms |
1112 KB |
Output is correct |
20 |
Correct |
7 ms |
1112 KB |
Output is correct |
21 |
Correct |
2 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1112 KB |
Output is correct |
2 |
Correct |
8 ms |
1368 KB |
Output is correct |
3 |
Correct |
9 ms |
1112 KB |
Output is correct |
4 |
Correct |
9 ms |
1116 KB |
Output is correct |
5 |
Correct |
5 ms |
1112 KB |
Output is correct |
6 |
Correct |
2 ms |
1112 KB |
Output is correct |
7 |
Correct |
9 ms |
1368 KB |
Output is correct |
8 |
Correct |
12 ms |
1112 KB |
Output is correct |
9 |
Correct |
10 ms |
1116 KB |
Output is correct |
10 |
Correct |
6 ms |
1116 KB |
Output is correct |
11 |
Correct |
3 ms |
1112 KB |
Output is correct |
12 |
Correct |
11 ms |
1112 KB |
Output is correct |
13 |
Correct |
16 ms |
1116 KB |
Output is correct |
14 |
Correct |
17 ms |
1112 KB |
Output is correct |
15 |
Correct |
6 ms |
1112 KB |
Output is correct |
16 |
Correct |
2 ms |
1112 KB |
Output is correct |
17 |
Correct |
12 ms |
1112 KB |
Output is correct |
18 |
Correct |
16 ms |
1112 KB |
Output is correct |
19 |
Correct |
14 ms |
1112 KB |
Output is correct |
20 |
Correct |
7 ms |
1112 KB |
Output is correct |
21 |
Correct |
2 ms |
1112 KB |
Output is correct |
22 |
Runtime error |
269 ms |
262144 KB |
Execution killed with signal 9 |
23 |
Halted |
0 ms |
0 KB |
- |