답안 #937675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937675 2024-03-04T10:28:48 Z zwezdinv Maze (JOI23_ho_t3) C++17
8 / 100
125 ms 79452 KB
#include <bits/stdc++.h>

struct node {
        int x, y, free, dist;
        node() = default;
        node(int x, int y, int free, int dist) : x(x), y(y), free(free), dist(dist) {}
};

std::vector<std::pair<int, int>> dir1 = {
        {0, 1},
        {0, -1},
        {1, 0},
        {-1, 0}
};
std::vector<std::pair<int, int>> dir2 = {
        {1, 1},
        {1, -1},
        {-1, 1},
        {-1, -1}
};

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

        int r, c, n;
        std::cin >> r >> c >> n;
        int sx, sy, fx, fy;
        std::cin >> sx >> sy >> fx >> fy;
        --sx, --sy, --fx, --fy;
        std::vector a(r, std::vector(c, '#'));
        for (auto& i : a) {
                for (auto& j : i) {
                        std::cin >> j;
                }
        }
        std::deque<node> que;
        std::vector used(r, std::vector(c, false));
        que.emplace_back(sx, sy, 0, 0);
        while (que.size()) {
                node u = que.front();
                que.pop_front();
                if (u.x == fx && u.y == fy) {
                        std::cout << u.dist << '\n';
                        break;
                }
                if (used[u.x][u.y]) continue;
                used[u.x][u.y] = true;
                for (auto [dx, dy] : dir1) {
                        int i = u.x + dx, j = u.y + dy;
                        if (i < 0 || i >= r || j < 0 || j >= c) continue;
                        if (a[i][j] == '.') {
                                que.emplace_front(i, j, std::max(u.free - 1, 0), u.dist);
                        }
                        if (u.free == 0) {
                                que.emplace_back(i, j, n - 1, u.dist + 1);
                        } else {
                                que.emplace_front(i, j, u.free - 1, u.dist);
                        }
                }
                for (auto [dx, dy] : dir2) {
                        int i = u.x + dx, j = u.y + dy;
                        if (i < 0 || i >= r || j < 0 || j >= c) continue;
                        if (u.free >= 2) {
                                que.emplace_front(i, j, u.free - 1, u.dist);
                        } else if (n >= 2) {
                                que.emplace_back(i, j, n - 1, u.dist + 1);
                        }
                }
        }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Correct 5 ms 604 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 10 ms 604 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 4 ms 3676 KB Output is correct
32 Correct 14 ms 812 KB Output is correct
33 Correct 8 ms 600 KB Output is correct
34 Correct 8 ms 604 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 9 ms 1420 KB Output is correct
37 Correct 11 ms 1164 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 99 ms 2304 KB Output is correct
40 Correct 6 ms 604 KB Output is correct
41 Correct 5 ms 676 KB Output is correct
42 Correct 17 ms 604 KB Output is correct
43 Correct 13 ms 600 KB Output is correct
44 Correct 29 ms 1116 KB Output is correct
45 Correct 27 ms 1372 KB Output is correct
46 Correct 97 ms 79452 KB Output is correct
47 Correct 125 ms 2640 KB Output is correct
48 Correct 70 ms 2140 KB Output is correct
49 Correct 57 ms 3160 KB Output is correct
50 Correct 41 ms 3164 KB Output is correct
51 Correct 104 ms 5972 KB Output is correct
52 Correct 71 ms 3396 KB Output is correct
53 Correct 79 ms 2588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Correct 5 ms 604 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 10 ms 604 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 4 ms 3676 KB Output is correct
32 Correct 14 ms 812 KB Output is correct
33 Correct 8 ms 600 KB Output is correct
34 Correct 8 ms 604 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 9 ms 1420 KB Output is correct
37 Correct 11 ms 1164 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 99 ms 2304 KB Output is correct
40 Correct 6 ms 604 KB Output is correct
41 Correct 5 ms 676 KB Output is correct
42 Correct 17 ms 604 KB Output is correct
43 Correct 13 ms 600 KB Output is correct
44 Correct 29 ms 1116 KB Output is correct
45 Correct 27 ms 1372 KB Output is correct
46 Correct 97 ms 79452 KB Output is correct
47 Correct 125 ms 2640 KB Output is correct
48 Correct 70 ms 2140 KB Output is correct
49 Correct 57 ms 3160 KB Output is correct
50 Correct 41 ms 3164 KB Output is correct
51 Correct 104 ms 5972 KB Output is correct
52 Correct 71 ms 3396 KB Output is correct
53 Correct 79 ms 2588 KB Output is correct
54 Incorrect 0 ms 348 KB Output isn't correct
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Correct 5 ms 604 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 10 ms 604 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 4 ms 3676 KB Output is correct
32 Correct 14 ms 812 KB Output is correct
33 Correct 8 ms 600 KB Output is correct
34 Correct 8 ms 604 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 9 ms 1420 KB Output is correct
37 Correct 11 ms 1164 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 99 ms 2304 KB Output is correct
40 Correct 6 ms 604 KB Output is correct
41 Correct 5 ms 676 KB Output is correct
42 Correct 17 ms 604 KB Output is correct
43 Correct 13 ms 600 KB Output is correct
44 Correct 29 ms 1116 KB Output is correct
45 Correct 27 ms 1372 KB Output is correct
46 Correct 97 ms 79452 KB Output is correct
47 Correct 125 ms 2640 KB Output is correct
48 Correct 70 ms 2140 KB Output is correct
49 Correct 57 ms 3160 KB Output is correct
50 Correct 41 ms 3164 KB Output is correct
51 Correct 104 ms 5972 KB Output is correct
52 Correct 71 ms 3396 KB Output is correct
53 Correct 79 ms 2588 KB Output is correct
54 Incorrect 0 ms 348 KB Output isn't correct
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Correct 5 ms 604 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 10 ms 604 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 4 ms 3676 KB Output is correct
32 Correct 14 ms 812 KB Output is correct
33 Correct 8 ms 600 KB Output is correct
34 Correct 8 ms 604 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 9 ms 1420 KB Output is correct
37 Correct 11 ms 1164 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 99 ms 2304 KB Output is correct
40 Correct 6 ms 604 KB Output is correct
41 Correct 5 ms 676 KB Output is correct
42 Correct 17 ms 604 KB Output is correct
43 Correct 13 ms 600 KB Output is correct
44 Correct 29 ms 1116 KB Output is correct
45 Correct 27 ms 1372 KB Output is correct
46 Correct 97 ms 79452 KB Output is correct
47 Correct 125 ms 2640 KB Output is correct
48 Correct 70 ms 2140 KB Output is correct
49 Correct 57 ms 3160 KB Output is correct
50 Correct 41 ms 3164 KB Output is correct
51 Correct 104 ms 5972 KB Output is correct
52 Correct 71 ms 3396 KB Output is correct
53 Correct 79 ms 2588 KB Output is correct
54 Incorrect 0 ms 348 KB Output isn't correct
55 Halted 0 ms 0 KB -