Submission #456178

# Submission time Handle Problem Language Result Execution time Memory
456178 2021-08-06T08:06:14 Z prvocislo Circle selection (APIO18_circle_selection) C++17
87 / 100
3000 ms 12472 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
typedef long long ll;
using namespace std;

const int maxn = 3e5 + 5, logn = 30;
const ll maxi = 1e9 + 5;
struct circle { int x, y, r; };
vector<circle> c(maxn);
bool in(const int& a, const int& b)
{
    return (c[a].r + c[b].r) * 1ll * (c[a].r + c[b].r)
        >= (c[a].x - c[b].x) * 1ll * (c[a].x - c[b].x) + (c[a].y - c[b].y) * 1ll * (c[a].y - c[b].y);
}
bool cmp(const int& a, const int& b)
{
    return (c[a].r == c[b].r ? a < b : c[a].r > c[b].r);
}
vector<pair<pair<int, int>, int> > o;
vector<int> ans(maxn, -1), ord(maxn, -1);
int n, r;
inline void process(const int& i)
{
    for (int l = -2; l <= 2; l++)
    {
        int x = (c[i].x >> r) + l;
        int y1 = max(-maxi, (((ll)c[i].y) >> ((ll)r)) - (1ll << ((ll)(r + 1))));
        int y2 = min(maxi, (((ll)c[i].y) >> ((ll)r)) + (1ll << ((ll)(r + 1))));
        auto it = lower_bound(o.begin(), o.end(), make_pair(make_pair(x, y1), -1));
        while (it != o.end() && it->first <= make_pair(x, y2))
        {
            if (ans[it->second] == -1 && in(it->second, i)) ans[it->second] = i;
            it++;
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> c[i].x >> c[i].y >> c[i].r;
        ord[i] = i;
    }
    sort(ord.begin(), ord.begin() + n, cmp);
    int id = 0;
    for (r = logn; r >= 0; r--)
    {
        o.clear();
        for (int i = 0; i < n; i++) if (ans[i] == -1)
            o.push_back({ {c[i].x >> r, c[i].y >> r}, i });
        sort(o.begin(), o.end());
        while (id != n && (!r || c[ord[id]].r >= (1 << (r - 1))))
        {
            if (ans[ord[id]] == -1) process(ord[id]);
            id++;
        }
    }
    for (int i = 0; i < n; i++) cout << ans[i] + 1 << " ";
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6092 KB Output is correct
2 Correct 3 ms 6092 KB Output is correct
3 Correct 3 ms 6092 KB Output is correct
4 Correct 3 ms 6092 KB Output is correct
5 Correct 3 ms 6092 KB Output is correct
6 Correct 4 ms 6092 KB Output is correct
7 Correct 4 ms 6092 KB Output is correct
8 Correct 4 ms 6208 KB Output is correct
9 Correct 4 ms 6092 KB Output is correct
10 Correct 4 ms 6092 KB Output is correct
11 Correct 4 ms 6092 KB Output is correct
12 Correct 4 ms 6092 KB Output is correct
13 Correct 3 ms 6092 KB Output is correct
14 Correct 4 ms 6092 KB Output is correct
15 Correct 5 ms 6092 KB Output is correct
16 Correct 4 ms 6092 KB Output is correct
17 Correct 5 ms 6216 KB Output is correct
18 Correct 4 ms 6220 KB Output is correct
19 Correct 7 ms 6348 KB Output is correct
20 Correct 7 ms 6348 KB Output is correct
21 Correct 7 ms 6348 KB Output is correct
22 Correct 19 ms 6480 KB Output is correct
23 Correct 20 ms 6352 KB Output is correct
24 Correct 18 ms 6364 KB Output is correct
25 Correct 18 ms 6356 KB Output is correct
26 Correct 18 ms 6360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 259 ms 12440 KB Output is correct
2 Correct 306 ms 12392 KB Output is correct
3 Correct 288 ms 12432 KB Output is correct
4 Correct 236 ms 12436 KB Output is correct
5 Correct 919 ms 12432 KB Output is correct
6 Correct 1111 ms 12428 KB Output is correct
7 Correct 948 ms 12440 KB Output is correct
8 Correct 985 ms 12468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6092 KB Output is correct
2 Correct 383 ms 7960 KB Output is correct
3 Correct 1390 ms 12360 KB Output is correct
4 Correct 1377 ms 12432 KB Output is correct
5 Correct 1524 ms 12468 KB Output is correct
6 Correct 591 ms 9380 KB Output is correct
7 Correct 265 ms 7804 KB Output is correct
8 Correct 52 ms 6668 KB Output is correct
9 Correct 1540 ms 12432 KB Output is correct
10 Correct 2062 ms 12468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1306 ms 12440 KB Output is correct
2 Correct 1533 ms 12468 KB Output is correct
3 Correct 1213 ms 12428 KB Output is correct
4 Correct 1279 ms 12432 KB Output is correct
5 Correct 1246 ms 12436 KB Output is correct
6 Correct 1118 ms 12468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6092 KB Output is correct
2 Correct 3 ms 6092 KB Output is correct
3 Correct 3 ms 6092 KB Output is correct
4 Correct 3 ms 6092 KB Output is correct
5 Correct 3 ms 6092 KB Output is correct
6 Correct 4 ms 6092 KB Output is correct
7 Correct 4 ms 6092 KB Output is correct
8 Correct 4 ms 6208 KB Output is correct
9 Correct 4 ms 6092 KB Output is correct
10 Correct 4 ms 6092 KB Output is correct
11 Correct 4 ms 6092 KB Output is correct
12 Correct 4 ms 6092 KB Output is correct
13 Correct 3 ms 6092 KB Output is correct
14 Correct 4 ms 6092 KB Output is correct
15 Correct 5 ms 6092 KB Output is correct
16 Correct 4 ms 6092 KB Output is correct
17 Correct 5 ms 6216 KB Output is correct
18 Correct 4 ms 6220 KB Output is correct
19 Correct 7 ms 6348 KB Output is correct
20 Correct 7 ms 6348 KB Output is correct
21 Correct 7 ms 6348 KB Output is correct
22 Correct 19 ms 6480 KB Output is correct
23 Correct 20 ms 6352 KB Output is correct
24 Correct 18 ms 6364 KB Output is correct
25 Correct 18 ms 6356 KB Output is correct
26 Correct 18 ms 6360 KB Output is correct
27 Correct 11 ms 6476 KB Output is correct
28 Correct 11 ms 6452 KB Output is correct
29 Correct 10 ms 6476 KB Output is correct
30 Correct 36 ms 6452 KB Output is correct
31 Correct 38 ms 6476 KB Output is correct
32 Correct 33 ms 6476 KB Output is correct
33 Correct 79 ms 8080 KB Output is correct
34 Correct 79 ms 7992 KB Output is correct
35 Correct 102 ms 7996 KB Output is correct
36 Correct 364 ms 8008 KB Output is correct
37 Correct 391 ms 7992 KB Output is correct
38 Correct 368 ms 7968 KB Output is correct
39 Correct 570 ms 7988 KB Output is correct
40 Correct 533 ms 7964 KB Output is correct
41 Correct 608 ms 7992 KB Output is correct
42 Correct 570 ms 7988 KB Output is correct
43 Correct 394 ms 8092 KB Output is correct
44 Correct 367 ms 7992 KB Output is correct
45 Correct 376 ms 7980 KB Output is correct
46 Correct 368 ms 7988 KB Output is correct
47 Correct 368 ms 8092 KB Output is correct
48 Correct 373 ms 7992 KB Output is correct
49 Correct 373 ms 7992 KB Output is correct
50 Correct 367 ms 7952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6092 KB Output is correct
2 Correct 3 ms 6092 KB Output is correct
3 Correct 3 ms 6092 KB Output is correct
4 Correct 3 ms 6092 KB Output is correct
5 Correct 3 ms 6092 KB Output is correct
6 Correct 4 ms 6092 KB Output is correct
7 Correct 4 ms 6092 KB Output is correct
8 Correct 4 ms 6208 KB Output is correct
9 Correct 4 ms 6092 KB Output is correct
10 Correct 4 ms 6092 KB Output is correct
11 Correct 4 ms 6092 KB Output is correct
12 Correct 4 ms 6092 KB Output is correct
13 Correct 3 ms 6092 KB Output is correct
14 Correct 4 ms 6092 KB Output is correct
15 Correct 5 ms 6092 KB Output is correct
16 Correct 4 ms 6092 KB Output is correct
17 Correct 5 ms 6216 KB Output is correct
18 Correct 4 ms 6220 KB Output is correct
19 Correct 7 ms 6348 KB Output is correct
20 Correct 7 ms 6348 KB Output is correct
21 Correct 7 ms 6348 KB Output is correct
22 Correct 19 ms 6480 KB Output is correct
23 Correct 20 ms 6352 KB Output is correct
24 Correct 18 ms 6364 KB Output is correct
25 Correct 18 ms 6356 KB Output is correct
26 Correct 18 ms 6360 KB Output is correct
27 Correct 259 ms 12440 KB Output is correct
28 Correct 306 ms 12392 KB Output is correct
29 Correct 288 ms 12432 KB Output is correct
30 Correct 236 ms 12436 KB Output is correct
31 Correct 919 ms 12432 KB Output is correct
32 Correct 1111 ms 12428 KB Output is correct
33 Correct 948 ms 12440 KB Output is correct
34 Correct 985 ms 12468 KB Output is correct
35 Correct 3 ms 6092 KB Output is correct
36 Correct 383 ms 7960 KB Output is correct
37 Correct 1390 ms 12360 KB Output is correct
38 Correct 1377 ms 12432 KB Output is correct
39 Correct 1524 ms 12468 KB Output is correct
40 Correct 591 ms 9380 KB Output is correct
41 Correct 265 ms 7804 KB Output is correct
42 Correct 52 ms 6668 KB Output is correct
43 Correct 1540 ms 12432 KB Output is correct
44 Correct 2062 ms 12468 KB Output is correct
45 Correct 1306 ms 12440 KB Output is correct
46 Correct 1533 ms 12468 KB Output is correct
47 Correct 1213 ms 12428 KB Output is correct
48 Correct 1279 ms 12432 KB Output is correct
49 Correct 1246 ms 12436 KB Output is correct
50 Correct 1118 ms 12468 KB Output is correct
51 Correct 11 ms 6476 KB Output is correct
52 Correct 11 ms 6452 KB Output is correct
53 Correct 10 ms 6476 KB Output is correct
54 Correct 36 ms 6452 KB Output is correct
55 Correct 38 ms 6476 KB Output is correct
56 Correct 33 ms 6476 KB Output is correct
57 Correct 79 ms 8080 KB Output is correct
58 Correct 79 ms 7992 KB Output is correct
59 Correct 102 ms 7996 KB Output is correct
60 Correct 364 ms 8008 KB Output is correct
61 Correct 391 ms 7992 KB Output is correct
62 Correct 368 ms 7968 KB Output is correct
63 Correct 570 ms 7988 KB Output is correct
64 Correct 533 ms 7964 KB Output is correct
65 Correct 608 ms 7992 KB Output is correct
66 Correct 570 ms 7988 KB Output is correct
67 Correct 394 ms 8092 KB Output is correct
68 Correct 367 ms 7992 KB Output is correct
69 Correct 376 ms 7980 KB Output is correct
70 Correct 368 ms 7988 KB Output is correct
71 Correct 368 ms 8092 KB Output is correct
72 Correct 373 ms 7992 KB Output is correct
73 Correct 373 ms 7992 KB Output is correct
74 Correct 367 ms 7952 KB Output is correct
75 Correct 285 ms 12432 KB Output is correct
76 Correct 374 ms 12472 KB Output is correct
77 Correct 306 ms 12428 KB Output is correct
78 Correct 239 ms 12468 KB Output is correct
79 Correct 449 ms 12468 KB Output is correct
80 Correct 265 ms 12468 KB Output is correct
81 Correct 1462 ms 12444 KB Output is correct
82 Correct 1377 ms 12444 KB Output is correct
83 Correct 1463 ms 12428 KB Output is correct
84 Correct 1797 ms 12436 KB Output is correct
85 Correct 1588 ms 12360 KB Output is correct
86 Correct 1410 ms 12444 KB Output is correct
87 Execution timed out 3059 ms 12436 KB Time limit exceeded
88 Halted 0 ms 0 KB -