Submission #1105781

# Submission time Handle Problem Language Result Execution time Memory
1105781 2024-10-27T18:17:04 Z vjudge1 Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 2976 KB
#include <bits/stdc++.h>

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::vector<int>> can(r + 1, std::vector<int>(c + 1));
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            if (a[i][j] == '.') {
                can[i][j] = 1;
            }
        }
    }
    for (int it = 1; it <= m; it++) {
        std::vector<std::vector<int>> aux(r + 1, std::vector<int>(c + 1, 0));
        for (int i = 1; i <= r; i++) {
            for (int j = 1; j <= c; j++) {
                if (a[i][j] == '#') {
                    continue;
                }
                if (s[it] == '?') {
                    for (int d = 0; d < 4; ++d) {
                        int x = i + dx[d];
                        int y = j + dy[d];
                        if (1 <= x && x <= r && 1 <= y && y <= c && can[x][y] == 1) {
                            aux[i][j] = 1;
                        }
                    }
                    continue;
                }
                if (s[it] == 'W' && j + 1 <= c && can[i][j + 1] == 1) {
                    aux[i][j] = 1; 
                }
                if (s[it] == 'E' && j - 1 >= 1 && can[i][j - 1] == 1) {
                    aux[i][j] = 1;
                }
                if (s[it] == 'N' && i + 1 <= r && can[i + 1][j] == 1) {
                    aux[i][j] = 1;
                }
                if (s[it] == 'S' && i - 1 >= 1 && can[i - 1][j] == 1) {
                    aux[i][j] = 1;
                }
            }
        }
        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 4 ms 336 KB Output is correct
2 Correct 5 ms 336 KB Output is correct
3 Correct 5 ms 336 KB Output is correct
4 Correct 5 ms 336 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 336 KB Output is correct
2 Correct 5 ms 336 KB Output is correct
3 Correct 5 ms 336 KB Output is correct
4 Correct 5 ms 336 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 6 ms 336 KB Output is correct
8 Correct 9 ms 336 KB Output is correct
9 Correct 7 ms 336 KB Output is correct
10 Correct 4 ms 572 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 9 ms 336 KB Output is correct
13 Correct 13 ms 576 KB Output is correct
14 Correct 14 ms 336 KB Output is correct
15 Correct 5 ms 336 KB Output is correct
16 Correct 2 ms 572 KB Output is correct
17 Correct 10 ms 336 KB Output is correct
18 Correct 17 ms 568 KB Output is correct
19 Correct 11 ms 336 KB Output is correct
20 Correct 5 ms 572 KB Output is correct
21 Correct 2 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 336 KB Output is correct
2 Correct 5 ms 336 KB Output is correct
3 Correct 5 ms 336 KB Output is correct
4 Correct 5 ms 336 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 6 ms 336 KB Output is correct
8 Correct 9 ms 336 KB Output is correct
9 Correct 7 ms 336 KB Output is correct
10 Correct 4 ms 572 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 9 ms 336 KB Output is correct
13 Correct 13 ms 576 KB Output is correct
14 Correct 14 ms 336 KB Output is correct
15 Correct 5 ms 336 KB Output is correct
16 Correct 2 ms 572 KB Output is correct
17 Correct 10 ms 336 KB Output is correct
18 Correct 17 ms 568 KB Output is correct
19 Correct 11 ms 336 KB Output is correct
20 Correct 5 ms 572 KB Output is correct
21 Correct 2 ms 472 KB Output is correct
22 Execution timed out 1059 ms 2976 KB Time limit exceeded
23 Halted 0 ms 0 KB -