Submission #1105782

# Submission time Handle Problem Language Result Execution time Memory
1105782 2024-10-27T18:25:39 Z vjudge1 Nautilus (BOI19_nautilus) C++17
100 / 100
134 ms 1208 KB
#include <bits/stdc++.h>

const int N = 505;

int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};

int main() {
    std::ios_base::sync_with_stdio(false); 
    std::cin.tie(nullptr);

    int r, c, m;
    std::string s;
    std::cin >> r >> c >> m;
    std::vector<std::vector<char>> a(r + 1, std::vector<char>(c + 1));
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            std::cin >> a[i][j];
        }
    }
    std::cin >> s;
    s = "#" + s;
    std::vector<std::bitset<N>> can(r + 2), good(r + 2);
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            if (a[i][j] == '.') {
                can[i][j] = 1;
                good[i][j] = 1;
            }
        }
    }
    for (int it = 1; it <= m; it++) {
        std::vector<std::bitset<N>> aux(r + 2);
        for (int i = 1; i <= r; ++i) {
            if (s[it] == '?') {
                aux[i] = can[i - 1] | can[i + 1];
                aux[i] |= can[i] << 1;
                aux[i] |= can[i] >> 1;
            }
            if (s[it] == 'W') {
                aux[i] = can[i] >> 1;
            } 
            if (s[it] == 'E') {
                aux[i] = can[i] << 1;
            }
            if (s[it] == 'N') {
                aux[i] = can[i + 1];
            }
            if (s[it] == 'S') {
                aux[i] = can[i - 1];
            }
            aux[i] &= good[i];
        }
        swap(can, aux);
    }
    int res = 0;
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            if (can[i][j] == 1) {
                res++;
            }
        }
    }
    std::cout << res << "\n";
    return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 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 336 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 504 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 400 KB Output is correct
16 Correct 2 ms 336 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 2 ms 336 KB Output is correct
21 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 336 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 504 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 400 KB Output is correct
16 Correct 2 ms 336 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 2 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 64 ms 592 KB Output is correct
23 Correct 59 ms 848 KB Output is correct
24 Correct 56 ms 848 KB Output is correct
25 Correct 57 ms 848 KB Output is correct
26 Correct 55 ms 848 KB Output is correct
27 Correct 100 ms 848 KB Output is correct
28 Correct 97 ms 932 KB Output is correct
29 Correct 95 ms 848 KB Output is correct
30 Correct 101 ms 848 KB Output is correct
31 Correct 95 ms 848 KB Output is correct
32 Correct 125 ms 836 KB Output is correct
33 Correct 127 ms 848 KB Output is correct
34 Correct 125 ms 1208 KB Output is correct
35 Correct 134 ms 848 KB Output is correct
36 Correct 128 ms 848 KB Output is correct