# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1091589 |
2024-09-21T12:57:00 Z |
gyg |
Nautilus (BOI19_nautilus) |
C++17 |
|
1000 ms |
1624 KB |
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
#define arr array
const int MX_R = 5e2 + 5, MX_C = 5e2 + 5, MX_N = 5e3 + 5;
int r, c, n;
bool wll[MX_R][MX_C];
arr<char, MX_N> mv;
bool ps[2][MX_R][MX_C];
void cmp() {
for (int i = 1; i <= r; i++)
for (int j = 1; j <= c; j++)
ps[0][i][j] = !wll[i][j];
for (int i = 1; i <= n; i++) {
int prty = i % 2, opp_prty = (i + 1) % 2;
if (mv[i] == 'W') {
for (int j = 1; j <= r; j++)
for (int k = 1; k <= c; k++)
ps[prty][j][k] = !wll[j][k] && ps[opp_prty][j][k + 1];
}
if (mv[i] == 'E') {
for (int j = 1; j <= r; j++)
for (int k = 1; k <= c; k++)
ps[prty][j][k] = !wll[j][k] && ps[opp_prty][j][k - 1];
}
if (mv[i] == 'S') {
for (int j = 1; j <= r; j++)
for (int k = 1; k <= c; k++)
ps[prty][j][k] = !wll[j][k] && ps[opp_prty][j - 1][k];
}
if (mv[i] == 'N') {
for (int j = 1; j <= r; j++)
for (int k = 1; k <= c; k++)
ps[prty][j][k] = !wll[j][k] && ps[opp_prty][j + 1][k];
}
if (mv[i] == '?') {
for (int j = 1; j <= r; j++)
for (int k = 1; k <= c; k++)
ps[prty][j][k] = !wll[j][k] && (ps[opp_prty][j][k + 1] || ps[opp_prty][j][k - 1] || ps[opp_prty][j + 1][k] || ps[opp_prty][j - 1][k]);
}
// cout << mv[i] << ": " << "----------------" << endl;
// for (int j = 1; j <= r; j++) {
// for (int k = 1; k <= c; k++) cout << ps[prty][j][k];
// cout << endl;
// }
}
}
int main() {
// freopen("nt.in", "r", stdin);
cin.sync_with_stdio(false), cin.tie(0);
cin >> r >> c >> n;
for (int i = 1; i <= r; i++) {
for (int j = 1; j <= c; j++) {
char x; cin >> x;
wll[i][j] = (x == '#');
}
}
for (int i = 1; i <= n; i++) cin >> mv[i];
cmp();
int ans = 0;
for (int i = 1; i <= r; i++)
for (int j = 1; j <= c; j++) ans += ps[n % 2][i][j];
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
4 ms |
604 KB |
Output is correct |
9 |
Correct |
4 ms |
856 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
856 KB |
Output is correct |
13 |
Correct |
2 ms |
632 KB |
Output is correct |
14 |
Correct |
4 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
628 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
4 ms |
604 KB |
Output is correct |
9 |
Correct |
4 ms |
856 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
856 KB |
Output is correct |
13 |
Correct |
2 ms |
632 KB |
Output is correct |
14 |
Correct |
4 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
628 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
671 ms |
1624 KB |
Output is correct |
23 |
Execution timed out |
1054 ms |
1368 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |