답안 #703098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703098 2023-02-26T06:04:44 Z Cyanmond Building Skyscrapers (CEOI19_skyscrapers) C++17
8 / 100
184 ms 8428 KB
#include <bits/stdc++.h>

struct Point {
    int r, c;
};
auto compPoint = [](Point a, Point b) {
    return std::make_pair(a.r, a.c) < std::make_pair(b.r, b.c);
};

std::pair<int, int> dxy[8] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}};

int main() {
    int N, T;
    std::cin >> N >> T;
    std::vector<Point> sks(N);
    for (auto &[r, c] : sks) {
        std::cin >> r >> c;
    }
    std::map<Point, int, decltype(compPoint)> skMap(compPoint);
    for (int i = 0; i < N; ++i) {
        skMap[sks[i]] = i;
    }

    std::vector<int> dist(N, -1);
    dist[0] = 0;
    std::queue<int> que;
    que.push(0);
    while (not que.empty()) {
        const auto f = que.front();
        que.pop();
        const auto &[r, c] = sks[f];
        for (const auto &[ar, ac] : dxy) {
            const int nr = r + ar, nc = c + ac;
            auto itr = skMap.find({nr, nc});
            if (itr == skMap.end()) {
                continue;
            }
            const int t = itr->second;
            if (dist[t] != -1) {
                continue;
            }
            dist[t] = dist[f] + 1;
            que.push(t);
        }
    }

    if (std::any_of(dist.begin(), dist.end(), [&](int x) {
        return x == -1;
    })) {
        std::cout << "NO" << std::endl;
        return 0;
    }
    std::cout << "YES" << std::endl;
    std::vector<std::vector<int>> distList(N);
    for (int i = 0; i < N; ++i) {
        distList[dist[i]].push_back(i);
    }
    for (const auto &vec : distList) {
        for (const auto e : vec) {
            std::cout << e + 1 << std::endl;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 0 ms 304 KB ans=NO N=4
4 Correct 0 ms 212 KB ans=YES N=5
5 Correct 1 ms 212 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 0 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 0 ms 212 KB ans=YES N=10
12 Correct 0 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 304 KB ans=YES N=8
15 Correct 1 ms 308 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 0 ms 304 KB ans=NO N=4
4 Correct 0 ms 212 KB ans=YES N=5
5 Correct 1 ms 212 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 0 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 0 ms 212 KB ans=YES N=10
12 Correct 0 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 304 KB ans=YES N=8
15 Correct 1 ms 308 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 1 ms 212 KB ans=YES N=17
18 Correct 1 ms 212 KB ans=YES N=25
19 Correct 1 ms 304 KB ans=YES N=100
20 Incorrect 1 ms 212 KB Added cell 111 (-4,-1) not reachable from infinity
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 0 ms 304 KB ans=NO N=4
4 Correct 0 ms 212 KB ans=YES N=5
5 Correct 1 ms 212 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 0 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 0 ms 212 KB ans=YES N=10
12 Correct 0 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 304 KB ans=YES N=8
15 Correct 1 ms 308 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 1 ms 212 KB ans=YES N=17
18 Correct 1 ms 212 KB ans=YES N=25
19 Correct 1 ms 304 KB ans=YES N=100
20 Incorrect 1 ms 212 KB Added cell 111 (-4,-1) not reachable from infinity
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 488 KB ans=NO N=1934
2 Correct 2 ms 468 KB ans=NO N=1965
3 Incorrect 5 ms 468 KB Added cell 351 (367,219) not reachable from infinity
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 0 ms 304 KB ans=NO N=4
4 Correct 0 ms 212 KB ans=YES N=5
5 Correct 1 ms 212 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 0 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 0 ms 212 KB ans=YES N=10
12 Correct 0 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 304 KB ans=YES N=8
15 Correct 1 ms 308 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 1 ms 212 KB ans=YES N=17
18 Correct 1 ms 212 KB ans=YES N=25
19 Correct 1 ms 304 KB ans=YES N=100
20 Incorrect 1 ms 212 KB Added cell 111 (-4,-1) not reachable from infinity
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 5716 KB ans=NO N=66151
2 Correct 50 ms 5596 KB ans=NO N=64333
3 Incorrect 184 ms 8428 KB Added cell 48044 (111,-24) not reachable from infinity
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 488 KB ans=NO N=1934
2 Correct 2 ms 468 KB ans=NO N=1965
3 Incorrect 5 ms 468 KB Added cell 351 (367,219) not reachable from infinity
4 Halted 0 ms 0 KB -