#include <bits/stdc++.h>
using namespace std;
void just_do_it();
int main() {
#ifdef KAMIRULEZ
freopen("kamirulez.inp", "r", stdin);
freopen("kamirulez.out", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
just_do_it();
return 0;
}
struct circle {
int x, y, r;
};
bool intersect(circle C1, circle C2) {
return 1LL * (C1.r + C2.r) * (C1.r + C2.r) >= 1LL * (C1.x - C2.x) * (C1.x - C2.x) + 1LL * (C1.y - C2.y) * (C1.y - C2.y);
}
const int maxn = 3e5 + 20;
circle C[maxn];
int res[maxn];
set<pair<int, int>> S;
map<pair<int, int>, set<int>> groups;
int n;
int floor(int a, int b) {
return (a / b) - (a % b && (a ^ b) < 0);
}
void build(int len) {
groups.clear();
for (auto p: S) {
int i = p.second;
int cx = floor(C[i].x, len);
int cy = floor(C[i].y, len);
groups[{cx, cy}].insert(i);
}
}
void just_do_it() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> C[i].x >> C[i].y >> C[i].r;
S.insert({-C[i].r, i});
}
int len = -1;
while (!S.empty()) {
int cur = S.begin()->second;
if (len == -1 || 1.5 * C[cur].r < len) {
len = C[cur].r;
build(len);
}
int cx = floor(C[cur].x, len);
int cy = floor(C[cur].y, len);
for (int i = -2; i <= 2; i++) {
for (int j = -2; j <= 2; j++) {
auto g_it = groups.find({cx + i, cy + j});
if (g_it == groups.end()) {
continue;
}
auto it = g_it->second.begin();
while (it != g_it->second.end()) {
int can = *it;
if (intersect(C[cur], C[can])) {
res[can] = cur;
it = g_it->second.erase(it);
S.erase({-C[can].r, can});
}
else {
it++;
}
}
}
}
}
for (int i = 1; i <= n; i++) {
cout << res[i] << " ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
5 ms |
852 KB |
Output is correct |
20 |
Correct |
5 ms |
852 KB |
Output is correct |
21 |
Correct |
5 ms |
884 KB |
Output is correct |
22 |
Correct |
14 ms |
1364 KB |
Output is correct |
23 |
Correct |
17 ms |
1348 KB |
Output is correct |
24 |
Correct |
15 ms |
1356 KB |
Output is correct |
25 |
Correct |
15 ms |
1356 KB |
Output is correct |
26 |
Correct |
13 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
602 ms |
35232 KB |
Output is correct |
2 |
Correct |
595 ms |
35276 KB |
Output is correct |
3 |
Correct |
691 ms |
35036 KB |
Output is correct |
4 |
Correct |
686 ms |
35412 KB |
Output is correct |
5 |
Correct |
627 ms |
35608 KB |
Output is correct |
6 |
Correct |
1074 ms |
48980 KB |
Output is correct |
7 |
Correct |
679 ms |
36776 KB |
Output is correct |
8 |
Correct |
819 ms |
39240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
240 KB |
Output is correct |
2 |
Correct |
618 ms |
21172 KB |
Output is correct |
3 |
Correct |
2379 ms |
63300 KB |
Output is correct |
4 |
Correct |
2385 ms |
63276 KB |
Output is correct |
5 |
Correct |
2505 ms |
58348 KB |
Output is correct |
6 |
Correct |
897 ms |
29900 KB |
Output is correct |
7 |
Correct |
333 ms |
15680 KB |
Output is correct |
8 |
Correct |
37 ms |
3468 KB |
Output is correct |
9 |
Correct |
2897 ms |
62688 KB |
Output is correct |
10 |
Correct |
2487 ms |
55736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1478 ms |
63560 KB |
Output is correct |
2 |
Correct |
1056 ms |
63324 KB |
Output is correct |
3 |
Correct |
739 ms |
42828 KB |
Output is correct |
4 |
Correct |
1132 ms |
63344 KB |
Output is correct |
5 |
Correct |
1089 ms |
63436 KB |
Output is correct |
6 |
Correct |
587 ms |
36016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
5 ms |
852 KB |
Output is correct |
20 |
Correct |
5 ms |
852 KB |
Output is correct |
21 |
Correct |
5 ms |
884 KB |
Output is correct |
22 |
Correct |
14 ms |
1364 KB |
Output is correct |
23 |
Correct |
17 ms |
1348 KB |
Output is correct |
24 |
Correct |
15 ms |
1356 KB |
Output is correct |
25 |
Correct |
15 ms |
1356 KB |
Output is correct |
26 |
Correct |
13 ms |
1364 KB |
Output is correct |
27 |
Correct |
10 ms |
1364 KB |
Output is correct |
28 |
Correct |
10 ms |
1364 KB |
Output is correct |
29 |
Correct |
10 ms |
1388 KB |
Output is correct |
30 |
Correct |
32 ms |
2368 KB |
Output is correct |
31 |
Correct |
29 ms |
2368 KB |
Output is correct |
32 |
Correct |
31 ms |
2348 KB |
Output is correct |
33 |
Correct |
166 ms |
11904 KB |
Output is correct |
34 |
Correct |
135 ms |
11856 KB |
Output is correct |
35 |
Correct |
136 ms |
11848 KB |
Output is correct |
36 |
Correct |
526 ms |
21184 KB |
Output is correct |
37 |
Correct |
601 ms |
21176 KB |
Output is correct |
38 |
Correct |
554 ms |
21288 KB |
Output is correct |
39 |
Correct |
988 ms |
19876 KB |
Output is correct |
40 |
Correct |
1106 ms |
19848 KB |
Output is correct |
41 |
Correct |
1282 ms |
19720 KB |
Output is correct |
42 |
Correct |
323 ms |
21152 KB |
Output is correct |
43 |
Correct |
322 ms |
21024 KB |
Output is correct |
44 |
Correct |
339 ms |
20952 KB |
Output is correct |
45 |
Correct |
331 ms |
20956 KB |
Output is correct |
46 |
Correct |
341 ms |
20944 KB |
Output is correct |
47 |
Correct |
309 ms |
21068 KB |
Output is correct |
48 |
Correct |
321 ms |
21052 KB |
Output is correct |
49 |
Correct |
329 ms |
20980 KB |
Output is correct |
50 |
Correct |
333 ms |
20976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
5 ms |
852 KB |
Output is correct |
20 |
Correct |
5 ms |
852 KB |
Output is correct |
21 |
Correct |
5 ms |
884 KB |
Output is correct |
22 |
Correct |
14 ms |
1364 KB |
Output is correct |
23 |
Correct |
17 ms |
1348 KB |
Output is correct |
24 |
Correct |
15 ms |
1356 KB |
Output is correct |
25 |
Correct |
15 ms |
1356 KB |
Output is correct |
26 |
Correct |
13 ms |
1364 KB |
Output is correct |
27 |
Correct |
602 ms |
35232 KB |
Output is correct |
28 |
Correct |
595 ms |
35276 KB |
Output is correct |
29 |
Correct |
691 ms |
35036 KB |
Output is correct |
30 |
Correct |
686 ms |
35412 KB |
Output is correct |
31 |
Correct |
627 ms |
35608 KB |
Output is correct |
32 |
Correct |
1074 ms |
48980 KB |
Output is correct |
33 |
Correct |
679 ms |
36776 KB |
Output is correct |
34 |
Correct |
819 ms |
39240 KB |
Output is correct |
35 |
Correct |
1 ms |
240 KB |
Output is correct |
36 |
Correct |
618 ms |
21172 KB |
Output is correct |
37 |
Correct |
2379 ms |
63300 KB |
Output is correct |
38 |
Correct |
2385 ms |
63276 KB |
Output is correct |
39 |
Correct |
2505 ms |
58348 KB |
Output is correct |
40 |
Correct |
897 ms |
29900 KB |
Output is correct |
41 |
Correct |
333 ms |
15680 KB |
Output is correct |
42 |
Correct |
37 ms |
3468 KB |
Output is correct |
43 |
Correct |
2897 ms |
62688 KB |
Output is correct |
44 |
Correct |
2487 ms |
55736 KB |
Output is correct |
45 |
Correct |
1478 ms |
63560 KB |
Output is correct |
46 |
Correct |
1056 ms |
63324 KB |
Output is correct |
47 |
Correct |
739 ms |
42828 KB |
Output is correct |
48 |
Correct |
1132 ms |
63344 KB |
Output is correct |
49 |
Correct |
1089 ms |
63436 KB |
Output is correct |
50 |
Correct |
587 ms |
36016 KB |
Output is correct |
51 |
Correct |
10 ms |
1364 KB |
Output is correct |
52 |
Correct |
10 ms |
1364 KB |
Output is correct |
53 |
Correct |
10 ms |
1388 KB |
Output is correct |
54 |
Correct |
32 ms |
2368 KB |
Output is correct |
55 |
Correct |
29 ms |
2368 KB |
Output is correct |
56 |
Correct |
31 ms |
2348 KB |
Output is correct |
57 |
Correct |
166 ms |
11904 KB |
Output is correct |
58 |
Correct |
135 ms |
11856 KB |
Output is correct |
59 |
Correct |
136 ms |
11848 KB |
Output is correct |
60 |
Correct |
526 ms |
21184 KB |
Output is correct |
61 |
Correct |
601 ms |
21176 KB |
Output is correct |
62 |
Correct |
554 ms |
21288 KB |
Output is correct |
63 |
Correct |
988 ms |
19876 KB |
Output is correct |
64 |
Correct |
1106 ms |
19848 KB |
Output is correct |
65 |
Correct |
1282 ms |
19720 KB |
Output is correct |
66 |
Correct |
323 ms |
21152 KB |
Output is correct |
67 |
Correct |
322 ms |
21024 KB |
Output is correct |
68 |
Correct |
339 ms |
20952 KB |
Output is correct |
69 |
Correct |
331 ms |
20956 KB |
Output is correct |
70 |
Correct |
341 ms |
20944 KB |
Output is correct |
71 |
Correct |
309 ms |
21068 KB |
Output is correct |
72 |
Correct |
321 ms |
21052 KB |
Output is correct |
73 |
Correct |
329 ms |
20980 KB |
Output is correct |
74 |
Correct |
333 ms |
20976 KB |
Output is correct |
75 |
Correct |
717 ms |
34972 KB |
Output is correct |
76 |
Correct |
693 ms |
35760 KB |
Output is correct |
77 |
Correct |
614 ms |
35788 KB |
Output is correct |
78 |
Correct |
713 ms |
35632 KB |
Output is correct |
79 |
Correct |
910 ms |
35724 KB |
Output is correct |
80 |
Correct |
619 ms |
35504 KB |
Output is correct |
81 |
Correct |
2443 ms |
63936 KB |
Output is correct |
82 |
Correct |
2518 ms |
63884 KB |
Output is correct |
83 |
Correct |
2428 ms |
63784 KB |
Output is correct |
84 |
Correct |
2484 ms |
63752 KB |
Output is correct |
85 |
Correct |
2384 ms |
63788 KB |
Output is correct |
86 |
Correct |
2431 ms |
63792 KB |
Output is correct |
87 |
Correct |
2705 ms |
63644 KB |
Output is correct |
88 |
Execution timed out |
3058 ms |
32176 KB |
Time limit exceeded |
89 |
Halted |
0 ms |
0 KB |
- |