Submission #1106234

# Submission time Handle Problem Language Result Execution time Memory
1106234 2024-10-29T15:39:30 Z cot7302 Nautilus (BOI19_nautilus) C++17
100 / 100
146 ms 816 KB
#include <bits/stdc++.h>
#define ALL(X) begin(X), end(X)
using namespace std;
using i64 = long long;

template <class T>
using vec = vector<T>;

template <class T>
istream& operator>>(istream& is, vec<T>& V) {
    for (auto& x : V) is >> x;
    return is;
}

constexpr int kN = 500;

bitset<kN> dp[2][kN + 2], mask[kN + 1];

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int R, C, M; cin >> R >> C >> M;
    for (int i = 0; i < R; i++) {
        string S; cin >> S;
        for (int j = 0; j < C; j++)
            mask[i + 1][j] = dp[1][i + 1][j] = (S[j] == '.');
    }
    string op; cin >> op;
    for (int t = 0; t < M; t++) {
        const char c = op[t];
        for (int i = 0; i < R; i++) {
            if (c == '?') {
                dp[t & 1][i + 1] = mask[i + 1] & 
                                    (dp[!(t & 1)][i] | dp[!(t & 1)][i + 2] |
                                    (dp[!(t & 1)][i + 1] << 1) | (dp[!(t & 1)][i + 1] >> 1));
            }
            else if (c == 'N')
                dp[t & 1][i + 1] = mask[i + 1] & dp[!(t & 1)][i + 2];
            else if (c == 'S')
                dp[t & 1][i + 1] = mask[i + 1] & dp[!(t & 1)][i];
            else if (c == 'W')
                dp[t & 1][i + 1] = mask[i + 1] & (dp[!(t & 1)][i + 1] >> 1);
            else if (c == 'E')
                dp[t & 1][i + 1] = mask[i + 1] & (dp[!(t & 1)][i + 1] << 1);
        }
    }
    int ans{};
    for (int i = 0; i < R; i++)
        for (int j = 0; j < C; j++)
            ans += dp[!(M & 1)][i + 1][j];
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 548 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 548 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 516 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 548 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 516 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 504 KB Output is correct
22 Correct 75 ms 592 KB Output is correct
23 Correct 74 ms 592 KB Output is correct
24 Correct 74 ms 816 KB Output is correct
25 Correct 74 ms 592 KB Output is correct
26 Correct 71 ms 592 KB Output is correct
27 Correct 113 ms 592 KB Output is correct
28 Correct 115 ms 592 KB Output is correct
29 Correct 114 ms 592 KB Output is correct
30 Correct 111 ms 760 KB Output is correct
31 Correct 109 ms 592 KB Output is correct
32 Correct 145 ms 592 KB Output is correct
33 Correct 145 ms 592 KB Output is correct
34 Correct 145 ms 592 KB Output is correct
35 Correct 144 ms 592 KB Output is correct
36 Correct 146 ms 760 KB Output is correct