# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
921419 |
2024-02-03T19:59:24 Z |
aykhn |
Nautilus (BOI19_nautilus) |
C++17 |
|
18 ms |
9092 KB |
#include <bits/stdc++.h>
// author: aykhn
using namespace std;
#define int long long
#define inf 0x3F3F3F3F
const int MXN = 1e2 + 5;
int n, m, K;
char mat[MXN][MXN];
int dp[MXN][MXN][MXN];
string s;
int A[4] = {0, 0, -1, 1};
int B[4] = {-1, 1, 0, 0};
int C[26], D[26];
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
C['S' - 'A'] = -1;
D['S' - 'A'] = 0;
C['N' - 'A'] = 1;
D['N' - 'A'] = 0;
C['W' - 'A'] = 0;
D['W' - 'A'] = 1;
C['E' - 'A'] = 0;
D['E' - 'A'] = -1;
cin >> n >> m >> K;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> mat[i][j];
dp[0][i][j] = (mat[i][j] != '#');
}
}
cin >> s;
s = "#" + s;
int res;
for (int k = 1; k <= K; k++)
{
res = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (mat[i][j] == '#') continue;
if (s[k] == '?')
{
for (int l = 0; l < 4; l++)
{
int x = i + A[l], y = j + B[l];
if (x >= 0 && x < n && y >= 0 && y < m) dp[k][i][j] |= dp[k - 1][x][y];
}
}
else
{
int x = i + C[s[k] - 'A'], y = j + D[s[k] - 'A'];
if (x >= 0 && x < n && y >= 0 && y < m) dp[k][i][j] |= dp[k - 1][x][y];
}
res += dp[k][i][j];
}
}
}
cout << res << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9052 KB |
Output is correct |
2 |
Correct |
7 ms |
8884 KB |
Output is correct |
3 |
Correct |
8 ms |
8876 KB |
Output is correct |
4 |
Correct |
7 ms |
9048 KB |
Output is correct |
5 |
Correct |
5 ms |
9052 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9052 KB |
Output is correct |
2 |
Correct |
7 ms |
8884 KB |
Output is correct |
3 |
Correct |
8 ms |
8876 KB |
Output is correct |
4 |
Correct |
7 ms |
9048 KB |
Output is correct |
5 |
Correct |
5 ms |
9052 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
9 ms |
9092 KB |
Output is correct |
8 |
Correct |
10 ms |
9052 KB |
Output is correct |
9 |
Correct |
9 ms |
8908 KB |
Output is correct |
10 |
Correct |
7 ms |
9052 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
12 ms |
9052 KB |
Output is correct |
13 |
Correct |
13 ms |
9052 KB |
Output is correct |
14 |
Correct |
12 ms |
9052 KB |
Output is correct |
15 |
Correct |
7 ms |
9048 KB |
Output is correct |
16 |
Correct |
2 ms |
1372 KB |
Output is correct |
17 |
Correct |
15 ms |
9052 KB |
Output is correct |
18 |
Correct |
18 ms |
9048 KB |
Output is correct |
19 |
Correct |
12 ms |
9052 KB |
Output is correct |
20 |
Correct |
8 ms |
9052 KB |
Output is correct |
21 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9052 KB |
Output is correct |
2 |
Correct |
7 ms |
8884 KB |
Output is correct |
3 |
Correct |
8 ms |
8876 KB |
Output is correct |
4 |
Correct |
7 ms |
9048 KB |
Output is correct |
5 |
Correct |
5 ms |
9052 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
9 ms |
9092 KB |
Output is correct |
8 |
Correct |
10 ms |
9052 KB |
Output is correct |
9 |
Correct |
9 ms |
8908 KB |
Output is correct |
10 |
Correct |
7 ms |
9052 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
12 ms |
9052 KB |
Output is correct |
13 |
Correct |
13 ms |
9052 KB |
Output is correct |
14 |
Correct |
12 ms |
9052 KB |
Output is correct |
15 |
Correct |
7 ms |
9048 KB |
Output is correct |
16 |
Correct |
2 ms |
1372 KB |
Output is correct |
17 |
Correct |
15 ms |
9052 KB |
Output is correct |
18 |
Correct |
18 ms |
9048 KB |
Output is correct |
19 |
Correct |
12 ms |
9052 KB |
Output is correct |
20 |
Correct |
8 ms |
9052 KB |
Output is correct |
21 |
Correct |
1 ms |
1372 KB |
Output is correct |
22 |
Runtime error |
1 ms |
860 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |