답안 #937666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937666 2024-03-04T10:22:37 Z zwezdinv Maze (JOI23_ho_t3) C++17
8 / 100
151 ms 79400 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 = {
        {0, 1},
        {0, -1},
        {1, 0},
        {-1, 0},
        {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);
                        }
                }
                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 >= abs(dx) + abs(dy)) {
                                que.emplace_front(i, j, u.free - 1, u.dist);
                        } else if (abs(dx) + abs(dy) <= n) {
                                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 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 344 KB Output is correct
11 Correct 0 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 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Correct 6 ms 588 KB Output is correct
23 Correct 5 ms 348 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 3 ms 604 KB Output is correct
29 Correct 13 ms 712 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 5 ms 3676 KB Output is correct
32 Correct 16 ms 824 KB Output is correct
33 Correct 11 ms 604 KB Output is correct
34 Correct 8 ms 604 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 10 ms 1600 KB Output is correct
37 Correct 15 ms 1116 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 129 ms 2300 KB Output is correct
40 Correct 6 ms 604 KB Output is correct
41 Correct 5 ms 676 KB Output is correct
42 Correct 21 ms 768 KB Output is correct
43 Correct 15 ms 604 KB Output is correct
44 Correct 32 ms 1320 KB Output is correct
45 Correct 31 ms 1392 KB Output is correct
46 Correct 109 ms 79400 KB Output is correct
47 Correct 151 ms 2896 KB Output is correct
48 Correct 93 ms 2140 KB Output is correct
49 Correct 52 ms 3164 KB Output is correct
50 Correct 42 ms 3164 KB Output is correct
51 Correct 122 ms 6564 KB Output is correct
52 Correct 82 ms 3644 KB Output is correct
53 Correct 110 ms 2584 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 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 344 KB Output is correct
11 Correct 0 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 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Correct 6 ms 588 KB Output is correct
23 Correct 5 ms 348 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 3 ms 604 KB Output is correct
29 Correct 13 ms 712 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 5 ms 3676 KB Output is correct
32 Correct 16 ms 824 KB Output is correct
33 Correct 11 ms 604 KB Output is correct
34 Correct 8 ms 604 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 10 ms 1600 KB Output is correct
37 Correct 15 ms 1116 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 129 ms 2300 KB Output is correct
40 Correct 6 ms 604 KB Output is correct
41 Correct 5 ms 676 KB Output is correct
42 Correct 21 ms 768 KB Output is correct
43 Correct 15 ms 604 KB Output is correct
44 Correct 32 ms 1320 KB Output is correct
45 Correct 31 ms 1392 KB Output is correct
46 Correct 109 ms 79400 KB Output is correct
47 Correct 151 ms 2896 KB Output is correct
48 Correct 93 ms 2140 KB Output is correct
49 Correct 52 ms 3164 KB Output is correct
50 Correct 42 ms 3164 KB Output is correct
51 Correct 122 ms 6564 KB Output is correct
52 Correct 82 ms 3644 KB Output is correct
53 Correct 110 ms 2584 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 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 344 KB Output is correct
11 Correct 0 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 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Correct 6 ms 588 KB Output is correct
23 Correct 5 ms 348 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 3 ms 604 KB Output is correct
29 Correct 13 ms 712 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 5 ms 3676 KB Output is correct
32 Correct 16 ms 824 KB Output is correct
33 Correct 11 ms 604 KB Output is correct
34 Correct 8 ms 604 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 10 ms 1600 KB Output is correct
37 Correct 15 ms 1116 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 129 ms 2300 KB Output is correct
40 Correct 6 ms 604 KB Output is correct
41 Correct 5 ms 676 KB Output is correct
42 Correct 21 ms 768 KB Output is correct
43 Correct 15 ms 604 KB Output is correct
44 Correct 32 ms 1320 KB Output is correct
45 Correct 31 ms 1392 KB Output is correct
46 Correct 109 ms 79400 KB Output is correct
47 Correct 151 ms 2896 KB Output is correct
48 Correct 93 ms 2140 KB Output is correct
49 Correct 52 ms 3164 KB Output is correct
50 Correct 42 ms 3164 KB Output is correct
51 Correct 122 ms 6564 KB Output is correct
52 Correct 82 ms 3644 KB Output is correct
53 Correct 110 ms 2584 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 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 344 KB Output is correct
11 Correct 0 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 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 1372 KB Output is correct
22 Correct 6 ms 588 KB Output is correct
23 Correct 5 ms 348 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 3 ms 604 KB Output is correct
29 Correct 13 ms 712 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 5 ms 3676 KB Output is correct
32 Correct 16 ms 824 KB Output is correct
33 Correct 11 ms 604 KB Output is correct
34 Correct 8 ms 604 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 10 ms 1600 KB Output is correct
37 Correct 15 ms 1116 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 129 ms 2300 KB Output is correct
40 Correct 6 ms 604 KB Output is correct
41 Correct 5 ms 676 KB Output is correct
42 Correct 21 ms 768 KB Output is correct
43 Correct 15 ms 604 KB Output is correct
44 Correct 32 ms 1320 KB Output is correct
45 Correct 31 ms 1392 KB Output is correct
46 Correct 109 ms 79400 KB Output is correct
47 Correct 151 ms 2896 KB Output is correct
48 Correct 93 ms 2140 KB Output is correct
49 Correct 52 ms 3164 KB Output is correct
50 Correct 42 ms 3164 KB Output is correct
51 Correct 122 ms 6564 KB Output is correct
52 Correct 82 ms 3644 KB Output is correct
53 Correct 110 ms 2584 KB Output is correct
54 Incorrect 0 ms 348 KB Output isn't correct
55 Halted 0 ms 0 KB -