답안 #519428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
519428 2022-01-26T10:51:16 Z KoD Drvca (COCI19_drvca) C++17
110 / 110
138 ms 12464 KB
#include <bits/stdc++.h>

using std::vector;
using std::array;
using std::pair;
using std::tuple;

void show(const vector<int>& v) {
    const int n = v.size();
    std::cout << n << '\n';
    for (int i = 0; i < n; ++i) {
        std::cout << v[i] << " \n"[i + 1 == n];
    }
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N;
    std::cin >> N;
    vector<int> A(N);
    for (auto& x : A) {
        std::cin >> x;
    }
    const auto try_seq = [&](const int first, const int dif) {
        std::multiset<int> set(A.begin(), A.end());
        std::multiset<int> dist;
        for (auto itr = set.begin(); std::next(itr) != set.end(); ++itr) {
            dist.insert(*std::next(itr) - *itr);
        }
        int element = first;
        vector<int> taken;
        while (true) {
            auto itr = set.find(element);
            if (itr == set.end()) {
                return;
            }
            if (itr != set.begin()) {
                dist.erase(dist.find(*itr - *std::prev(itr)));
            }
            if (std::next(itr) != set.end()) {
                dist.erase(dist.find(*std::next(itr) - *itr));
            }
            if (itr != set.begin() and std::next(itr) != set.end()) {
                dist.insert(*std::next(itr) - *std::prev(itr));
            }
            taken.push_back(element);
            set.erase(itr);
            if (dist.empty() or *dist.begin() == *dist.rbegin()) {
                show(taken);
                show(vector<int>(set.begin(), set.end()));
                std::exit(EXIT_SUCCESS);
            }
            element += dif;
        }
    };
    std::sort(A.begin(), A.end());
    try_seq(A[0], A[1] - A[0]);
    try_seq(A[0], A[2] - A[0]);
    try_seq(A[1], A[2] - A[1]);
    std::cout << -1 << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 308 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 0 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 12076 KB Output is correct
2 Correct 76 ms 11952 KB Output is correct
3 Correct 81 ms 11980 KB Output is correct
4 Correct 61 ms 11968 KB Output is correct
5 Correct 81 ms 12080 KB Output is correct
6 Correct 60 ms 12044 KB Output is correct
7 Correct 72 ms 11964 KB Output is correct
8 Correct 59 ms 12124 KB Output is correct
9 Correct 59 ms 11344 KB Output is correct
10 Correct 71 ms 11956 KB Output is correct
11 Correct 54 ms 12372 KB Output is correct
12 Correct 0 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 308 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 0 ms 316 KB Output is correct
31 Correct 74 ms 12076 KB Output is correct
32 Correct 76 ms 11952 KB Output is correct
33 Correct 81 ms 11980 KB Output is correct
34 Correct 61 ms 11968 KB Output is correct
35 Correct 81 ms 12080 KB Output is correct
36 Correct 60 ms 12044 KB Output is correct
37 Correct 72 ms 11964 KB Output is correct
38 Correct 59 ms 12124 KB Output is correct
39 Correct 59 ms 11344 KB Output is correct
40 Correct 71 ms 11956 KB Output is correct
41 Correct 54 ms 12372 KB Output is correct
42 Correct 0 ms 308 KB Output is correct
43 Correct 85 ms 11964 KB Output is correct
44 Correct 138 ms 11316 KB Output is correct
45 Correct 54 ms 11436 KB Output is correct
46 Correct 64 ms 12052 KB Output is correct
47 Correct 132 ms 11060 KB Output is correct
48 Correct 58 ms 11456 KB Output is correct
49 Correct 80 ms 12096 KB Output is correct
50 Correct 111 ms 11156 KB Output is correct
51 Correct 54 ms 11460 KB Output is correct
52 Correct 68 ms 12032 KB Output is correct
53 Correct 130 ms 11020 KB Output is correct
54 Correct 55 ms 11388 KB Output is correct
55 Correct 68 ms 11992 KB Output is correct
56 Correct 75 ms 11972 KB Output is correct
57 Correct 48 ms 12464 KB Output is correct
58 Correct 1 ms 332 KB Output is correct