#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int n;
vector <int> x, y, r;
vector <int> _kill;
void init() {
cin >> n;
x.resize(n);
y.resize(n);
r.resize(n);
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i] >> r[i];
}
}
bool inter(int i, int j) {
return (ll)(x[i] - x[j]) * (x[i] - x[j]) + (ll)(y[i] - y[j]) * (y[i] - y[j]) <= (ll)(r[i] + r[j]) * (r[i] + r[j]);
}
map <pair <int, int>, vector <int>> who;
void rebuild(int B) {
who.clear();
for (int i = 0; i < n; ++i) {
if (_kill[i] != -1) continue;
int xx = x[i] / B;
int yy = y[i] / B;
who[make_pair(xx, yy)].push_back(i);
}
}
void solve() {
_kill.resize(n, -1);
vector <int> idx(n);
iota(idx.begin(), idx.end(), 0);
sort(idx.begin(), idx.end(), [&] (int i, int j) {
if (r[i] != r[j]) return r[i] > r[j];
return i < j;
});
int uk = 0;
int B = 2e9 + 7;
while (true) {
while (uk < n && _kill[idx[uk]] != -1) ++uk;
if (uk == n) break;
int cur = idx[uk];
if ((r[cur] << 1) <= B) {
B = r[cur];
rebuild(B);
}
_kill[cur] = cur;
int xx = x[cur] / B;
int yy = y[cur] / B;
for (int cx = xx - 2; cx <= xx + 2; ++cx) {
for (int cy = yy - 2; cy <= yy + 2; ++cy) {
if (who.count(make_pair(cx, cy))) {
for (auto j : who[make_pair(cx, cy)]) {
if (_kill[j] == -1 && inter(cur, j)) {
_kill[j] = cur;
}
}
}
}
}
}
for (int i = 0; i < n; ++i) {
cout << _kill[i] + 1 << ' ';
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
init();
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
448 KB |
Output is correct |
4 |
Correct |
2 ms |
524 KB |
Output is correct |
5 |
Correct |
2 ms |
544 KB |
Output is correct |
6 |
Correct |
2 ms |
544 KB |
Output is correct |
7 |
Correct |
2 ms |
560 KB |
Output is correct |
8 |
Correct |
2 ms |
560 KB |
Output is correct |
9 |
Correct |
2 ms |
560 KB |
Output is correct |
10 |
Correct |
2 ms |
560 KB |
Output is correct |
11 |
Correct |
2 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
636 KB |
Output is correct |
13 |
Correct |
3 ms |
636 KB |
Output is correct |
14 |
Correct |
2 ms |
636 KB |
Output is correct |
15 |
Correct |
3 ms |
636 KB |
Output is correct |
16 |
Correct |
3 ms |
636 KB |
Output is correct |
17 |
Correct |
3 ms |
636 KB |
Output is correct |
18 |
Correct |
3 ms |
636 KB |
Output is correct |
19 |
Correct |
5 ms |
764 KB |
Output is correct |
20 |
Correct |
6 ms |
764 KB |
Output is correct |
21 |
Correct |
5 ms |
780 KB |
Output is correct |
22 |
Correct |
17 ms |
1308 KB |
Output is correct |
23 |
Correct |
18 ms |
1324 KB |
Output is correct |
24 |
Correct |
20 ms |
1332 KB |
Output is correct |
25 |
Correct |
15 ms |
1340 KB |
Output is correct |
26 |
Correct |
18 ms |
1344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
217 ms |
8708 KB |
Output is correct |
2 |
Correct |
193 ms |
9352 KB |
Output is correct |
3 |
Correct |
223 ms |
9868 KB |
Output is correct |
4 |
Correct |
192 ms |
9868 KB |
Output is correct |
5 |
Correct |
262 ms |
9868 KB |
Output is correct |
6 |
Correct |
788 ms |
24764 KB |
Output is correct |
7 |
Correct |
300 ms |
24764 KB |
Output is correct |
8 |
Correct |
387 ms |
24764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
24764 KB |
Output is correct |
2 |
Correct |
520 ms |
24764 KB |
Output is correct |
3 |
Correct |
1979 ms |
41476 KB |
Output is correct |
4 |
Correct |
2207 ms |
49472 KB |
Output is correct |
5 |
Correct |
1886 ms |
51212 KB |
Output is correct |
6 |
Correct |
619 ms |
51212 KB |
Output is correct |
7 |
Correct |
243 ms |
51212 KB |
Output is correct |
8 |
Correct |
38 ms |
51212 KB |
Output is correct |
9 |
Correct |
2194 ms |
71880 KB |
Output is correct |
10 |
Correct |
1700 ms |
73492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1825 ms |
81156 KB |
Output is correct |
2 |
Correct |
1295 ms |
88380 KB |
Output is correct |
3 |
Correct |
484 ms |
88380 KB |
Output is correct |
4 |
Correct |
1339 ms |
104176 KB |
Output is correct |
5 |
Correct |
1323 ms |
111872 KB |
Output is correct |
6 |
Correct |
301 ms |
111872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
448 KB |
Output is correct |
4 |
Correct |
2 ms |
524 KB |
Output is correct |
5 |
Correct |
2 ms |
544 KB |
Output is correct |
6 |
Correct |
2 ms |
544 KB |
Output is correct |
7 |
Correct |
2 ms |
560 KB |
Output is correct |
8 |
Correct |
2 ms |
560 KB |
Output is correct |
9 |
Correct |
2 ms |
560 KB |
Output is correct |
10 |
Correct |
2 ms |
560 KB |
Output is correct |
11 |
Correct |
2 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
636 KB |
Output is correct |
13 |
Correct |
3 ms |
636 KB |
Output is correct |
14 |
Correct |
2 ms |
636 KB |
Output is correct |
15 |
Correct |
3 ms |
636 KB |
Output is correct |
16 |
Correct |
3 ms |
636 KB |
Output is correct |
17 |
Correct |
3 ms |
636 KB |
Output is correct |
18 |
Correct |
3 ms |
636 KB |
Output is correct |
19 |
Correct |
5 ms |
764 KB |
Output is correct |
20 |
Correct |
6 ms |
764 KB |
Output is correct |
21 |
Correct |
5 ms |
780 KB |
Output is correct |
22 |
Correct |
17 ms |
1308 KB |
Output is correct |
23 |
Correct |
18 ms |
1324 KB |
Output is correct |
24 |
Correct |
20 ms |
1332 KB |
Output is correct |
25 |
Correct |
15 ms |
1340 KB |
Output is correct |
26 |
Correct |
18 ms |
1344 KB |
Output is correct |
27 |
Correct |
9 ms |
111872 KB |
Output is correct |
28 |
Correct |
8 ms |
111872 KB |
Output is correct |
29 |
Correct |
9 ms |
111872 KB |
Output is correct |
30 |
Correct |
35 ms |
111872 KB |
Output is correct |
31 |
Correct |
33 ms |
111872 KB |
Output is correct |
32 |
Correct |
32 ms |
111872 KB |
Output is correct |
33 |
Correct |
67 ms |
111872 KB |
Output is correct |
34 |
Correct |
66 ms |
111872 KB |
Output is correct |
35 |
Correct |
70 ms |
111872 KB |
Output is correct |
36 |
Correct |
446 ms |
111872 KB |
Output is correct |
37 |
Correct |
469 ms |
111872 KB |
Output is correct |
38 |
Correct |
453 ms |
111872 KB |
Output is correct |
39 |
Correct |
338 ms |
111872 KB |
Output is correct |
40 |
Correct |
347 ms |
111872 KB |
Output is correct |
41 |
Correct |
411 ms |
111872 KB |
Output is correct |
42 |
Correct |
314 ms |
111872 KB |
Output is correct |
43 |
Correct |
358 ms |
111872 KB |
Output is correct |
44 |
Correct |
336 ms |
111872 KB |
Output is correct |
45 |
Correct |
324 ms |
111872 KB |
Output is correct |
46 |
Correct |
334 ms |
111872 KB |
Output is correct |
47 |
Correct |
329 ms |
111872 KB |
Output is correct |
48 |
Correct |
333 ms |
111872 KB |
Output is correct |
49 |
Correct |
323 ms |
111872 KB |
Output is correct |
50 |
Correct |
343 ms |
111872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
448 KB |
Output is correct |
4 |
Correct |
2 ms |
524 KB |
Output is correct |
5 |
Correct |
2 ms |
544 KB |
Output is correct |
6 |
Correct |
2 ms |
544 KB |
Output is correct |
7 |
Correct |
2 ms |
560 KB |
Output is correct |
8 |
Correct |
2 ms |
560 KB |
Output is correct |
9 |
Correct |
2 ms |
560 KB |
Output is correct |
10 |
Correct |
2 ms |
560 KB |
Output is correct |
11 |
Correct |
2 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
636 KB |
Output is correct |
13 |
Correct |
3 ms |
636 KB |
Output is correct |
14 |
Correct |
2 ms |
636 KB |
Output is correct |
15 |
Correct |
3 ms |
636 KB |
Output is correct |
16 |
Correct |
3 ms |
636 KB |
Output is correct |
17 |
Correct |
3 ms |
636 KB |
Output is correct |
18 |
Correct |
3 ms |
636 KB |
Output is correct |
19 |
Correct |
5 ms |
764 KB |
Output is correct |
20 |
Correct |
6 ms |
764 KB |
Output is correct |
21 |
Correct |
5 ms |
780 KB |
Output is correct |
22 |
Correct |
17 ms |
1308 KB |
Output is correct |
23 |
Correct |
18 ms |
1324 KB |
Output is correct |
24 |
Correct |
20 ms |
1332 KB |
Output is correct |
25 |
Correct |
15 ms |
1340 KB |
Output is correct |
26 |
Correct |
18 ms |
1344 KB |
Output is correct |
27 |
Correct |
217 ms |
8708 KB |
Output is correct |
28 |
Correct |
193 ms |
9352 KB |
Output is correct |
29 |
Correct |
223 ms |
9868 KB |
Output is correct |
30 |
Correct |
192 ms |
9868 KB |
Output is correct |
31 |
Correct |
262 ms |
9868 KB |
Output is correct |
32 |
Correct |
788 ms |
24764 KB |
Output is correct |
33 |
Correct |
300 ms |
24764 KB |
Output is correct |
34 |
Correct |
387 ms |
24764 KB |
Output is correct |
35 |
Correct |
2 ms |
24764 KB |
Output is correct |
36 |
Correct |
520 ms |
24764 KB |
Output is correct |
37 |
Correct |
1979 ms |
41476 KB |
Output is correct |
38 |
Correct |
2207 ms |
49472 KB |
Output is correct |
39 |
Correct |
1886 ms |
51212 KB |
Output is correct |
40 |
Correct |
619 ms |
51212 KB |
Output is correct |
41 |
Correct |
243 ms |
51212 KB |
Output is correct |
42 |
Correct |
38 ms |
51212 KB |
Output is correct |
43 |
Correct |
2194 ms |
71880 KB |
Output is correct |
44 |
Correct |
1700 ms |
73492 KB |
Output is correct |
45 |
Correct |
1825 ms |
81156 KB |
Output is correct |
46 |
Correct |
1295 ms |
88380 KB |
Output is correct |
47 |
Correct |
484 ms |
88380 KB |
Output is correct |
48 |
Correct |
1339 ms |
104176 KB |
Output is correct |
49 |
Correct |
1323 ms |
111872 KB |
Output is correct |
50 |
Correct |
301 ms |
111872 KB |
Output is correct |
51 |
Correct |
9 ms |
111872 KB |
Output is correct |
52 |
Correct |
8 ms |
111872 KB |
Output is correct |
53 |
Correct |
9 ms |
111872 KB |
Output is correct |
54 |
Correct |
35 ms |
111872 KB |
Output is correct |
55 |
Correct |
33 ms |
111872 KB |
Output is correct |
56 |
Correct |
32 ms |
111872 KB |
Output is correct |
57 |
Correct |
67 ms |
111872 KB |
Output is correct |
58 |
Correct |
66 ms |
111872 KB |
Output is correct |
59 |
Correct |
70 ms |
111872 KB |
Output is correct |
60 |
Correct |
446 ms |
111872 KB |
Output is correct |
61 |
Correct |
469 ms |
111872 KB |
Output is correct |
62 |
Correct |
453 ms |
111872 KB |
Output is correct |
63 |
Correct |
338 ms |
111872 KB |
Output is correct |
64 |
Correct |
347 ms |
111872 KB |
Output is correct |
65 |
Correct |
411 ms |
111872 KB |
Output is correct |
66 |
Correct |
314 ms |
111872 KB |
Output is correct |
67 |
Correct |
358 ms |
111872 KB |
Output is correct |
68 |
Correct |
336 ms |
111872 KB |
Output is correct |
69 |
Correct |
324 ms |
111872 KB |
Output is correct |
70 |
Correct |
334 ms |
111872 KB |
Output is correct |
71 |
Correct |
329 ms |
111872 KB |
Output is correct |
72 |
Correct |
333 ms |
111872 KB |
Output is correct |
73 |
Correct |
323 ms |
111872 KB |
Output is correct |
74 |
Correct |
343 ms |
111872 KB |
Output is correct |
75 |
Correct |
262 ms |
111872 KB |
Output is correct |
76 |
Correct |
214 ms |
111872 KB |
Output is correct |
77 |
Correct |
208 ms |
115984 KB |
Output is correct |
78 |
Correct |
202 ms |
124832 KB |
Output is correct |
79 |
Correct |
250 ms |
132416 KB |
Output is correct |
80 |
Correct |
205 ms |
142368 KB |
Output is correct |
81 |
Correct |
2090 ms |
182156 KB |
Output is correct |
82 |
Correct |
2160 ms |
190240 KB |
Output is correct |
83 |
Correct |
2190 ms |
197920 KB |
Output is correct |
84 |
Correct |
2207 ms |
206228 KB |
Output is correct |
85 |
Correct |
2048 ms |
214248 KB |
Output is correct |
86 |
Correct |
2079 ms |
222184 KB |
Output is correct |
87 |
Correct |
2484 ms |
230136 KB |
Output is correct |
88 |
Correct |
1454 ms |
230136 KB |
Output is correct |
89 |
Correct |
1541 ms |
232060 KB |
Output is correct |
90 |
Correct |
1521 ms |
235480 KB |
Output is correct |
91 |
Correct |
1499 ms |
238860 KB |
Output is correct |
92 |
Correct |
1544 ms |
242304 KB |
Output is correct |
93 |
Correct |
1603 ms |
254156 KB |
Output is correct |
94 |
Correct |
1706 ms |
261368 KB |
Output is correct |
95 |
Correct |
1603 ms |
268356 KB |
Output is correct |
96 |
Correct |
1682 ms |
275388 KB |
Output is correct |
97 |
Correct |
2529 ms |
282244 KB |
Output is correct |
98 |
Correct |
1051 ms |
282244 KB |
Output is correct |
99 |
Correct |
1582 ms |
296692 KB |
Output is correct |
100 |
Correct |
1541 ms |
303568 KB |
Output is correct |
101 |
Correct |
1508 ms |
303940 KB |
Output is correct |
102 |
Correct |
1770 ms |
317380 KB |
Output is correct |
103 |
Correct |
2424 ms |
324420 KB |
Output is correct |
104 |
Correct |
1669 ms |
329796 KB |
Output is correct |
105 |
Correct |
1294 ms |
334368 KB |
Output is correct |
106 |
Correct |
1228 ms |
339980 KB |
Output is correct |
107 |
Correct |
1227 ms |
347772 KB |
Output is correct |
108 |
Correct |
1268 ms |
354396 KB |
Output is correct |
109 |
Correct |
1265 ms |
362232 KB |
Output is correct |
110 |
Correct |
1238 ms |
369424 KB |
Output is correct |
111 |
Correct |
1289 ms |
374672 KB |
Output is correct |
112 |
Correct |
1242 ms |
382472 KB |
Output is correct |
113 |
Correct |
1253 ms |
388980 KB |
Output is correct |
114 |
Correct |
1245 ms |
396276 KB |
Output is correct |
115 |
Correct |
1335 ms |
403992 KB |
Output is correct |
116 |
Correct |
1242 ms |
411756 KB |
Output is correct |