#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<int, set<pair<int, 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].insert({cy, 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 || C[cur].r * 2 < len) {
len = C[cur].r;
build(len);
}
int cx = floor(C[cur].x, len);
int cy = floor(C[cur].y, len);
auto g_it = groups.lower_bound(cx - 2);
while (g_it != groups.end()) {
if (g_it->first > cx + 2) {
break;
}
auto it = g_it->second.lower_bound({cy - 2, -1});
while (it != g_it->second.end()) {
if (it->first > cy + 2) {
break;
}
int can = it->second;
if (intersect(C[cur], C[can])) {
res[can] = cur;
it = g_it->second.erase(it);
S.erase({-C[can].r, can});
}
else {
it++;
}
}
g_it++;
}
}
for (int i = 1; i <= n; i++) {
cout << res[i] << " ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 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 |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
324 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 |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
5 ms |
948 KB |
Output is correct |
20 |
Correct |
6 ms |
980 KB |
Output is correct |
21 |
Correct |
6 ms |
980 KB |
Output is correct |
22 |
Correct |
11 ms |
1236 KB |
Output is correct |
23 |
Correct |
8 ms |
980 KB |
Output is correct |
24 |
Correct |
8 ms |
1368 KB |
Output is correct |
25 |
Correct |
8 ms |
1496 KB |
Output is correct |
26 |
Correct |
8 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
689 ms |
36680 KB |
Output is correct |
2 |
Correct |
652 ms |
36540 KB |
Output is correct |
3 |
Correct |
719 ms |
36312 KB |
Output is correct |
4 |
Correct |
649 ms |
36520 KB |
Output is correct |
5 |
Correct |
673 ms |
36992 KB |
Output is correct |
6 |
Correct |
946 ms |
50436 KB |
Output is correct |
7 |
Correct |
699 ms |
37932 KB |
Output is correct |
8 |
Correct |
707 ms |
40412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
341 ms |
13204 KB |
Output is correct |
3 |
Correct |
1236 ms |
38476 KB |
Output is correct |
4 |
Correct |
1206 ms |
38444 KB |
Output is correct |
5 |
Correct |
1336 ms |
35848 KB |
Output is correct |
6 |
Correct |
512 ms |
20012 KB |
Output is correct |
7 |
Correct |
214 ms |
10948 KB |
Output is correct |
8 |
Correct |
23 ms |
3536 KB |
Output is correct |
9 |
Correct |
1434 ms |
36992 KB |
Output is correct |
10 |
Correct |
1417 ms |
35760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
780 ms |
43180 KB |
Output is correct |
2 |
Correct |
679 ms |
63724 KB |
Output is correct |
3 |
Correct |
664 ms |
35172 KB |
Output is correct |
4 |
Correct |
737 ms |
61604 KB |
Output is correct |
5 |
Correct |
715 ms |
62744 KB |
Output is correct |
6 |
Correct |
585 ms |
34876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 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 |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
324 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 |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
5 ms |
948 KB |
Output is correct |
20 |
Correct |
6 ms |
980 KB |
Output is correct |
21 |
Correct |
6 ms |
980 KB |
Output is correct |
22 |
Correct |
11 ms |
1236 KB |
Output is correct |
23 |
Correct |
8 ms |
980 KB |
Output is correct |
24 |
Correct |
8 ms |
1368 KB |
Output is correct |
25 |
Correct |
8 ms |
1496 KB |
Output is correct |
26 |
Correct |
8 ms |
1364 KB |
Output is correct |
27 |
Correct |
11 ms |
1620 KB |
Output is correct |
28 |
Correct |
10 ms |
1604 KB |
Output is correct |
29 |
Correct |
11 ms |
1628 KB |
Output is correct |
30 |
Correct |
17 ms |
1744 KB |
Output is correct |
31 |
Correct |
16 ms |
2152 KB |
Output is correct |
32 |
Correct |
15 ms |
2144 KB |
Output is correct |
33 |
Correct |
152 ms |
12108 KB |
Output is correct |
34 |
Correct |
156 ms |
12076 KB |
Output is correct |
35 |
Correct |
194 ms |
12052 KB |
Output is correct |
36 |
Correct |
261 ms |
15708 KB |
Output is correct |
37 |
Correct |
298 ms |
15420 KB |
Output is correct |
38 |
Correct |
284 ms |
14256 KB |
Output is correct |
39 |
Correct |
832 ms |
12152 KB |
Output is correct |
40 |
Correct |
795 ms |
12048 KB |
Output is correct |
41 |
Correct |
865 ms |
12104 KB |
Output is correct |
42 |
Correct |
177 ms |
12160 KB |
Output is correct |
43 |
Correct |
177 ms |
21212 KB |
Output is correct |
44 |
Correct |
190 ms |
21144 KB |
Output is correct |
45 |
Correct |
187 ms |
21240 KB |
Output is correct |
46 |
Correct |
210 ms |
21200 KB |
Output is correct |
47 |
Correct |
176 ms |
21292 KB |
Output is correct |
48 |
Correct |
206 ms |
21180 KB |
Output is correct |
49 |
Correct |
216 ms |
21144 KB |
Output is correct |
50 |
Correct |
188 ms |
21168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 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 |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
324 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 |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
5 ms |
948 KB |
Output is correct |
20 |
Correct |
6 ms |
980 KB |
Output is correct |
21 |
Correct |
6 ms |
980 KB |
Output is correct |
22 |
Correct |
11 ms |
1236 KB |
Output is correct |
23 |
Correct |
8 ms |
980 KB |
Output is correct |
24 |
Correct |
8 ms |
1368 KB |
Output is correct |
25 |
Correct |
8 ms |
1496 KB |
Output is correct |
26 |
Correct |
8 ms |
1364 KB |
Output is correct |
27 |
Correct |
689 ms |
36680 KB |
Output is correct |
28 |
Correct |
652 ms |
36540 KB |
Output is correct |
29 |
Correct |
719 ms |
36312 KB |
Output is correct |
30 |
Correct |
649 ms |
36520 KB |
Output is correct |
31 |
Correct |
673 ms |
36992 KB |
Output is correct |
32 |
Correct |
946 ms |
50436 KB |
Output is correct |
33 |
Correct |
699 ms |
37932 KB |
Output is correct |
34 |
Correct |
707 ms |
40412 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
341 ms |
13204 KB |
Output is correct |
37 |
Correct |
1236 ms |
38476 KB |
Output is correct |
38 |
Correct |
1206 ms |
38444 KB |
Output is correct |
39 |
Correct |
1336 ms |
35848 KB |
Output is correct |
40 |
Correct |
512 ms |
20012 KB |
Output is correct |
41 |
Correct |
214 ms |
10948 KB |
Output is correct |
42 |
Correct |
23 ms |
3536 KB |
Output is correct |
43 |
Correct |
1434 ms |
36992 KB |
Output is correct |
44 |
Correct |
1417 ms |
35760 KB |
Output is correct |
45 |
Correct |
780 ms |
43180 KB |
Output is correct |
46 |
Correct |
679 ms |
63724 KB |
Output is correct |
47 |
Correct |
664 ms |
35172 KB |
Output is correct |
48 |
Correct |
737 ms |
61604 KB |
Output is correct |
49 |
Correct |
715 ms |
62744 KB |
Output is correct |
50 |
Correct |
585 ms |
34876 KB |
Output is correct |
51 |
Correct |
11 ms |
1620 KB |
Output is correct |
52 |
Correct |
10 ms |
1604 KB |
Output is correct |
53 |
Correct |
11 ms |
1628 KB |
Output is correct |
54 |
Correct |
17 ms |
1744 KB |
Output is correct |
55 |
Correct |
16 ms |
2152 KB |
Output is correct |
56 |
Correct |
15 ms |
2144 KB |
Output is correct |
57 |
Correct |
152 ms |
12108 KB |
Output is correct |
58 |
Correct |
156 ms |
12076 KB |
Output is correct |
59 |
Correct |
194 ms |
12052 KB |
Output is correct |
60 |
Correct |
261 ms |
15708 KB |
Output is correct |
61 |
Correct |
298 ms |
15420 KB |
Output is correct |
62 |
Correct |
284 ms |
14256 KB |
Output is correct |
63 |
Correct |
832 ms |
12152 KB |
Output is correct |
64 |
Correct |
795 ms |
12048 KB |
Output is correct |
65 |
Correct |
865 ms |
12104 KB |
Output is correct |
66 |
Correct |
177 ms |
12160 KB |
Output is correct |
67 |
Correct |
177 ms |
21212 KB |
Output is correct |
68 |
Correct |
190 ms |
21144 KB |
Output is correct |
69 |
Correct |
187 ms |
21240 KB |
Output is correct |
70 |
Correct |
210 ms |
21200 KB |
Output is correct |
71 |
Correct |
176 ms |
21292 KB |
Output is correct |
72 |
Correct |
206 ms |
21180 KB |
Output is correct |
73 |
Correct |
216 ms |
21144 KB |
Output is correct |
74 |
Correct |
188 ms |
21168 KB |
Output is correct |
75 |
Correct |
698 ms |
35312 KB |
Output is correct |
76 |
Correct |
735 ms |
35740 KB |
Output is correct |
77 |
Correct |
645 ms |
35708 KB |
Output is correct |
78 |
Correct |
695 ms |
35596 KB |
Output is correct |
79 |
Correct |
753 ms |
35636 KB |
Output is correct |
80 |
Correct |
588 ms |
35416 KB |
Output is correct |
81 |
Correct |
1278 ms |
38284 KB |
Output is correct |
82 |
Correct |
1313 ms |
40080 KB |
Output is correct |
83 |
Correct |
1244 ms |
40072 KB |
Output is correct |
84 |
Correct |
1179 ms |
37008 KB |
Output is correct |
85 |
Correct |
1263 ms |
38884 KB |
Output is correct |
86 |
Correct |
1293 ms |
40856 KB |
Output is correct |
87 |
Correct |
1193 ms |
35848 KB |
Output is correct |
88 |
Execution timed out |
3025 ms |
32428 KB |
Time limit exceeded |
89 |
Halted |
0 ms |
0 KB |
- |