Submission #630127

# Submission time Handle Problem Language Result Execution time Memory
630127 2022-08-15T17:47:59 Z elkernos Circle selection (APIO18_circle_selection) C++17
100 / 100
1155 ms 25140 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll sq(int x)
{
    return (ll)x * x;
}

struct C {
    int x, y, r;
    void read() { cin >> x >> y >> r; }
    bool inter(const C &he) const { return sq(x - he.x) + sq(y - he.y) <= sq(r + he.r); }
};

struct T {
    int x, y, id;
    T(int xx, int yy, int iid) : x(xx), y(yy), id(iid) {}
    bool operator<(const T &he) const { return tie(x, y) < tie(he.x, he.y); }
};

const int oo = 1e9 + 7;

int32_t main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> ans(n, -1), ord(n);
    vector<C> c(n);
    for(int i = 0; i < n; i++) {
        c[i].read();
        ord[i] = i;
    }
    sort(ord.begin(), ord.end(), [&](auto a, auto b) {
        return c[a].r == c[b].r ? a < b : c[a].r > c[b].r;
    });
    for(int rep = 30; rep >= 1; rep--) {
        vector<T> aa;
        for(int i = 0; i < n; i++) {
            if(ans[i] == -1) {
                aa.emplace_back(c[i].x >> rep, c[i].y >> rep, i);
            }
        }
        sort(aa.begin(), aa.end());
        auto zrob = [&](int i) {
            for(int k = -2; k <= 2; k++) {
                int x = (c[i].x >> rep) - k;
                int lo = (c[i].y >> rep) - 2;
                int hi = (c[i].y >> rep) + 2;
                auto it = lower_bound(aa.begin(), aa.end(), T{x, lo, -1});
                while(it != aa.end() && tie(it->x, it->y) <= tie(x, hi)) {
                    if(ans[it->id] == -1 && c[i].inter(c[it->id])) {
                        ans[it->id] = i;
                    }
                    it++;
                }
            }
        };
        int p = 0;
        while(p < n && c[ord[p]].r >= (1 << (rep - 1))) {
            if(ans[ord[p]] == -1) {
                zrob(ord[p]);
            }
            p++;
        }
    }
    for(int i = 0; i < n; i++) {
        cout << ans[i] + 1 << " ";
    }
    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 4 ms 724 KB Output is correct
22 Correct 10 ms 700 KB Output is correct
23 Correct 10 ms 700 KB Output is correct
24 Correct 10 ms 712 KB Output is correct
25 Correct 11 ms 700 KB Output is correct
26 Correct 12 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 203 ms 22528 KB Output is correct
2 Correct 240 ms 22528 KB Output is correct
3 Correct 214 ms 22572 KB Output is correct
4 Correct 182 ms 19244 KB Output is correct
5 Correct 592 ms 20652 KB Output is correct
6 Correct 677 ms 20692 KB Output is correct
7 Correct 584 ms 20780 KB Output is correct
8 Correct 632 ms 20624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 225 ms 7880 KB Output is correct
3 Correct 849 ms 24136 KB Output is correct
4 Correct 825 ms 24036 KB Output is correct
5 Correct 702 ms 23680 KB Output is correct
6 Correct 330 ms 12664 KB Output is correct
7 Correct 184 ms 6688 KB Output is correct
8 Correct 33 ms 1716 KB Output is correct
9 Correct 803 ms 24048 KB Output is correct
10 Correct 663 ms 24360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 806 ms 23848 KB Output is correct
2 Correct 1108 ms 23092 KB Output is correct
3 Correct 377 ms 24348 KB Output is correct
4 Correct 895 ms 23488 KB Output is correct
5 Correct 906 ms 23648 KB Output is correct
6 Correct 333 ms 24544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 4 ms 724 KB Output is correct
22 Correct 10 ms 700 KB Output is correct
23 Correct 10 ms 700 KB Output is correct
24 Correct 10 ms 712 KB Output is correct
25 Correct 11 ms 700 KB Output is correct
26 Correct 12 ms 700 KB Output is correct
27 Correct 8 ms 1108 KB Output is correct
28 Correct 7 ms 1124 KB Output is correct
29 Correct 6 ms 1076 KB Output is correct
30 Correct 23 ms 1100 KB Output is correct
31 Correct 22 ms 1096 KB Output is correct
32 Correct 22 ms 1108 KB Output is correct
33 Correct 67 ms 6988 KB Output is correct
34 Correct 60 ms 7020 KB Output is correct
35 Correct 73 ms 7960 KB Output is correct
36 Correct 271 ms 7732 KB Output is correct
37 Correct 276 ms 7764 KB Output is correct
38 Correct 269 ms 7684 KB Output is correct
39 Correct 256 ms 6116 KB Output is correct
40 Correct 319 ms 6116 KB Output is correct
41 Correct 256 ms 6132 KB Output is correct
42 Correct 183 ms 6848 KB Output is correct
43 Correct 280 ms 7608 KB Output is correct
44 Correct 281 ms 7612 KB Output is correct
45 Correct 285 ms 7612 KB Output is correct
46 Correct 269 ms 7740 KB Output is correct
47 Correct 293 ms 7640 KB Output is correct
48 Correct 276 ms 7612 KB Output is correct
49 Correct 284 ms 7608 KB Output is correct
50 Correct 271 ms 7644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 4 ms 724 KB Output is correct
22 Correct 10 ms 700 KB Output is correct
23 Correct 10 ms 700 KB Output is correct
24 Correct 10 ms 712 KB Output is correct
25 Correct 11 ms 700 KB Output is correct
26 Correct 12 ms 700 KB Output is correct
27 Correct 203 ms 22528 KB Output is correct
28 Correct 240 ms 22528 KB Output is correct
29 Correct 214 ms 22572 KB Output is correct
30 Correct 182 ms 19244 KB Output is correct
31 Correct 592 ms 20652 KB Output is correct
32 Correct 677 ms 20692 KB Output is correct
33 Correct 584 ms 20780 KB Output is correct
34 Correct 632 ms 20624 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 225 ms 7880 KB Output is correct
37 Correct 849 ms 24136 KB Output is correct
38 Correct 825 ms 24036 KB Output is correct
39 Correct 702 ms 23680 KB Output is correct
40 Correct 330 ms 12664 KB Output is correct
41 Correct 184 ms 6688 KB Output is correct
42 Correct 33 ms 1716 KB Output is correct
43 Correct 803 ms 24048 KB Output is correct
44 Correct 663 ms 24360 KB Output is correct
45 Correct 806 ms 23848 KB Output is correct
46 Correct 1108 ms 23092 KB Output is correct
47 Correct 377 ms 24348 KB Output is correct
48 Correct 895 ms 23488 KB Output is correct
49 Correct 906 ms 23648 KB Output is correct
50 Correct 333 ms 24544 KB Output is correct
51 Correct 8 ms 1108 KB Output is correct
52 Correct 7 ms 1124 KB Output is correct
53 Correct 6 ms 1076 KB Output is correct
54 Correct 23 ms 1100 KB Output is correct
55 Correct 22 ms 1096 KB Output is correct
56 Correct 22 ms 1108 KB Output is correct
57 Correct 67 ms 6988 KB Output is correct
58 Correct 60 ms 7020 KB Output is correct
59 Correct 73 ms 7960 KB Output is correct
60 Correct 271 ms 7732 KB Output is correct
61 Correct 276 ms 7764 KB Output is correct
62 Correct 269 ms 7684 KB Output is correct
63 Correct 256 ms 6116 KB Output is correct
64 Correct 319 ms 6116 KB Output is correct
65 Correct 256 ms 6132 KB Output is correct
66 Correct 183 ms 6848 KB Output is correct
67 Correct 280 ms 7608 KB Output is correct
68 Correct 281 ms 7612 KB Output is correct
69 Correct 285 ms 7612 KB Output is correct
70 Correct 269 ms 7740 KB Output is correct
71 Correct 293 ms 7640 KB Output is correct
72 Correct 276 ms 7612 KB Output is correct
73 Correct 284 ms 7608 KB Output is correct
74 Correct 271 ms 7644 KB Output is correct
75 Correct 264 ms 25140 KB Output is correct
76 Correct 268 ms 24780 KB Output is correct
77 Correct 287 ms 24996 KB Output is correct
78 Correct 245 ms 21400 KB Output is correct
79 Correct 387 ms 24588 KB Output is correct
80 Correct 240 ms 21476 KB Output is correct
81 Correct 950 ms 24044 KB Output is correct
82 Correct 956 ms 23924 KB Output is correct
83 Correct 935 ms 23708 KB Output is correct
84 Correct 983 ms 24336 KB Output is correct
85 Correct 912 ms 23820 KB Output is correct
86 Correct 962 ms 23964 KB Output is correct
87 Correct 875 ms 23976 KB Output is correct
88 Correct 1071 ms 19364 KB Output is correct
89 Correct 1002 ms 19508 KB Output is correct
90 Correct 1155 ms 19440 KB Output is correct
91 Correct 953 ms 19344 KB Output is correct
92 Correct 1022 ms 19412 KB Output is correct
93 Correct 1006 ms 22868 KB Output is correct
94 Correct 968 ms 23480 KB Output is correct
95 Correct 1071 ms 22896 KB Output is correct
96 Correct 981 ms 23008 KB Output is correct
97 Correct 1148 ms 22928 KB Output is correct
98 Correct 739 ms 23236 KB Output is correct
99 Correct 1057 ms 23120 KB Output is correct
100 Correct 1092 ms 22836 KB Output is correct
101 Correct 743 ms 23320 KB Output is correct
102 Correct 877 ms 22936 KB Output is correct
103 Correct 941 ms 23040 KB Output is correct
104 Correct 924 ms 22680 KB Output is correct
105 Correct 555 ms 20876 KB Output is correct
106 Correct 779 ms 23692 KB Output is correct
107 Correct 781 ms 23768 KB Output is correct
108 Correct 836 ms 23768 KB Output is correct
109 Correct 766 ms 23656 KB Output is correct
110 Correct 773 ms 23780 KB Output is correct
111 Correct 812 ms 23772 KB Output is correct
112 Correct 768 ms 23676 KB Output is correct
113 Correct 813 ms 23704 KB Output is correct
114 Correct 770 ms 23668 KB Output is correct
115 Correct 806 ms 23856 KB Output is correct
116 Correct 755 ms 23768 KB Output is correct