#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+10;
int n;
pair<int, int> a[N];
int b[N], del[N];
map<pair<int, int>, vector<int>> mp;
bool check(int i, int j){
return ((a[i].first-a[j].first)*(a[i].first-a[j].first)+(a[i].second-a[j].second)*(a[i].second-a[j].second))<=(b[i]+b[j])*(b[i]+b[j]);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int x=0;
cin >> n;
for (int i=1; i<=n; ++i){
cin >> a[i].first >> a[i].second >> b[i];
a[i].first+=1e9; a[i].second+=1e9;
x=max(x, b[i]);
}
vector<int> v(n); iota(v.begin(), v.end(), 1);
sort(v.begin(), v.end(), [&](int k, int l){
return make_pair(b[k], -k)>make_pair(b[l], -l);
});
auto build=[&](){
mp.clear();
for (int i=1; i<=n; ++i) if (!del[i]){
mp[{a[i].first/x, a[i].second/x}].push_back(i);
}
};
build();
for (int i:v){
if (del[i]) continue;
if (b[i]<=x/2){
x/=2;
build();
}
for (int j=a[i].first/x-2; j<=a[i].first/x+2; ++j){
for (int k=a[i].second/x-2; k<=a[i].second/x+2; ++k){
if (!mp.count({j, k})) continue;
for (int l:mp[{j, k}]) if (!del[l] && check(i, l)) del[l]=i;
}
}
}
for (int i=1; i<=n; ++i) cout << del[i] << " \n"[i==n];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4440 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4440 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
3 ms |
4696 KB |
Output is correct |
20 |
Correct |
2 ms |
4700 KB |
Output is correct |
21 |
Correct |
3 ms |
4700 KB |
Output is correct |
22 |
Correct |
11 ms |
5212 KB |
Output is correct |
23 |
Correct |
13 ms |
5212 KB |
Output is correct |
24 |
Correct |
11 ms |
5212 KB |
Output is correct |
25 |
Correct |
10 ms |
5192 KB |
Output is correct |
26 |
Correct |
11 ms |
5212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
112 ms |
14520 KB |
Output is correct |
2 |
Correct |
113 ms |
14636 KB |
Output is correct |
3 |
Correct |
137 ms |
16296 KB |
Output is correct |
4 |
Correct |
108 ms |
15460 KB |
Output is correct |
5 |
Correct |
151 ms |
18672 KB |
Output is correct |
6 |
Correct |
553 ms |
30940 KB |
Output is correct |
7 |
Correct |
227 ms |
20260 KB |
Output is correct |
8 |
Correct |
250 ms |
22372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
384 ms |
17484 KB |
Output is correct |
3 |
Correct |
1617 ms |
46856 KB |
Output is correct |
4 |
Correct |
1691 ms |
55132 KB |
Output is correct |
5 |
Correct |
1521 ms |
48584 KB |
Output is correct |
6 |
Correct |
423 ms |
26740 KB |
Output is correct |
7 |
Correct |
190 ms |
15496 KB |
Output is correct |
8 |
Correct |
26 ms |
6748 KB |
Output is correct |
9 |
Correct |
1925 ms |
54076 KB |
Output is correct |
10 |
Correct |
1383 ms |
47572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1297 ms |
46888 KB |
Output is correct |
2 |
Correct |
918 ms |
53908 KB |
Output is correct |
3 |
Correct |
378 ms |
34180 KB |
Output is correct |
4 |
Correct |
946 ms |
54436 KB |
Output is correct |
5 |
Correct |
881 ms |
54472 KB |
Output is correct |
6 |
Correct |
178 ms |
28012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4440 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4440 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
3 ms |
4696 KB |
Output is correct |
20 |
Correct |
2 ms |
4700 KB |
Output is correct |
21 |
Correct |
3 ms |
4700 KB |
Output is correct |
22 |
Correct |
11 ms |
5212 KB |
Output is correct |
23 |
Correct |
13 ms |
5212 KB |
Output is correct |
24 |
Correct |
11 ms |
5212 KB |
Output is correct |
25 |
Correct |
10 ms |
5192 KB |
Output is correct |
26 |
Correct |
11 ms |
5212 KB |
Output is correct |
27 |
Correct |
5 ms |
4700 KB |
Output is correct |
28 |
Correct |
4 ms |
4700 KB |
Output is correct |
29 |
Correct |
5 ms |
4700 KB |
Output is correct |
30 |
Correct |
27 ms |
5720 KB |
Output is correct |
31 |
Correct |
28 ms |
5724 KB |
Output is correct |
32 |
Correct |
30 ms |
5724 KB |
Output is correct |
33 |
Correct |
39 ms |
7652 KB |
Output is correct |
34 |
Correct |
40 ms |
7804 KB |
Output is correct |
35 |
Correct |
46 ms |
7040 KB |
Output is correct |
36 |
Correct |
312 ms |
17596 KB |
Output is correct |
37 |
Correct |
305 ms |
17592 KB |
Output is correct |
38 |
Correct |
337 ms |
17612 KB |
Output is correct |
39 |
Correct |
362 ms |
16180 KB |
Output is correct |
40 |
Correct |
349 ms |
16156 KB |
Output is correct |
41 |
Correct |
339 ms |
16132 KB |
Output is correct |
42 |
Correct |
209 ms |
17576 KB |
Output is correct |
43 |
Correct |
216 ms |
17232 KB |
Output is correct |
44 |
Correct |
215 ms |
17236 KB |
Output is correct |
45 |
Correct |
225 ms |
17344 KB |
Output is correct |
46 |
Correct |
258 ms |
17272 KB |
Output is correct |
47 |
Correct |
212 ms |
17336 KB |
Output is correct |
48 |
Correct |
221 ms |
17232 KB |
Output is correct |
49 |
Correct |
219 ms |
17352 KB |
Output is correct |
50 |
Correct |
225 ms |
17348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4440 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4440 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
3 ms |
4696 KB |
Output is correct |
20 |
Correct |
2 ms |
4700 KB |
Output is correct |
21 |
Correct |
3 ms |
4700 KB |
Output is correct |
22 |
Correct |
11 ms |
5212 KB |
Output is correct |
23 |
Correct |
13 ms |
5212 KB |
Output is correct |
24 |
Correct |
11 ms |
5212 KB |
Output is correct |
25 |
Correct |
10 ms |
5192 KB |
Output is correct |
26 |
Correct |
11 ms |
5212 KB |
Output is correct |
27 |
Correct |
112 ms |
14520 KB |
Output is correct |
28 |
Correct |
113 ms |
14636 KB |
Output is correct |
29 |
Correct |
137 ms |
16296 KB |
Output is correct |
30 |
Correct |
108 ms |
15460 KB |
Output is correct |
31 |
Correct |
151 ms |
18672 KB |
Output is correct |
32 |
Correct |
553 ms |
30940 KB |
Output is correct |
33 |
Correct |
227 ms |
20260 KB |
Output is correct |
34 |
Correct |
250 ms |
22372 KB |
Output is correct |
35 |
Correct |
1 ms |
4444 KB |
Output is correct |
36 |
Correct |
384 ms |
17484 KB |
Output is correct |
37 |
Correct |
1617 ms |
46856 KB |
Output is correct |
38 |
Correct |
1691 ms |
55132 KB |
Output is correct |
39 |
Correct |
1521 ms |
48584 KB |
Output is correct |
40 |
Correct |
423 ms |
26740 KB |
Output is correct |
41 |
Correct |
190 ms |
15496 KB |
Output is correct |
42 |
Correct |
26 ms |
6748 KB |
Output is correct |
43 |
Correct |
1925 ms |
54076 KB |
Output is correct |
44 |
Correct |
1383 ms |
47572 KB |
Output is correct |
45 |
Correct |
1297 ms |
46888 KB |
Output is correct |
46 |
Correct |
918 ms |
53908 KB |
Output is correct |
47 |
Correct |
378 ms |
34180 KB |
Output is correct |
48 |
Correct |
946 ms |
54436 KB |
Output is correct |
49 |
Correct |
881 ms |
54472 KB |
Output is correct |
50 |
Correct |
178 ms |
28012 KB |
Output is correct |
51 |
Correct |
5 ms |
4700 KB |
Output is correct |
52 |
Correct |
4 ms |
4700 KB |
Output is correct |
53 |
Correct |
5 ms |
4700 KB |
Output is correct |
54 |
Correct |
27 ms |
5720 KB |
Output is correct |
55 |
Correct |
28 ms |
5724 KB |
Output is correct |
56 |
Correct |
30 ms |
5724 KB |
Output is correct |
57 |
Correct |
39 ms |
7652 KB |
Output is correct |
58 |
Correct |
40 ms |
7804 KB |
Output is correct |
59 |
Correct |
46 ms |
7040 KB |
Output is correct |
60 |
Correct |
312 ms |
17596 KB |
Output is correct |
61 |
Correct |
305 ms |
17592 KB |
Output is correct |
62 |
Correct |
337 ms |
17612 KB |
Output is correct |
63 |
Correct |
362 ms |
16180 KB |
Output is correct |
64 |
Correct |
349 ms |
16156 KB |
Output is correct |
65 |
Correct |
339 ms |
16132 KB |
Output is correct |
66 |
Correct |
209 ms |
17576 KB |
Output is correct |
67 |
Correct |
216 ms |
17232 KB |
Output is correct |
68 |
Correct |
215 ms |
17236 KB |
Output is correct |
69 |
Correct |
225 ms |
17344 KB |
Output is correct |
70 |
Correct |
258 ms |
17272 KB |
Output is correct |
71 |
Correct |
212 ms |
17336 KB |
Output is correct |
72 |
Correct |
221 ms |
17232 KB |
Output is correct |
73 |
Correct |
219 ms |
17352 KB |
Output is correct |
74 |
Correct |
225 ms |
17348 KB |
Output is correct |
75 |
Correct |
159 ms |
24428 KB |
Output is correct |
76 |
Correct |
125 ms |
23508 KB |
Output is correct |
77 |
Correct |
123 ms |
26836 KB |
Output is correct |
78 |
Correct |
140 ms |
25604 KB |
Output is correct |
79 |
Correct |
157 ms |
24660 KB |
Output is correct |
80 |
Correct |
149 ms |
25716 KB |
Output is correct |
81 |
Correct |
1513 ms |
54912 KB |
Output is correct |
82 |
Correct |
1488 ms |
54752 KB |
Output is correct |
83 |
Correct |
1572 ms |
54688 KB |
Output is correct |
84 |
Correct |
1602 ms |
55192 KB |
Output is correct |
85 |
Correct |
1495 ms |
54928 KB |
Output is correct |
86 |
Correct |
1358 ms |
54968 KB |
Output is correct |
87 |
Correct |
1698 ms |
54728 KB |
Output is correct |
88 |
Correct |
1567 ms |
45888 KB |
Output is correct |
89 |
Correct |
1365 ms |
45852 KB |
Output is correct |
90 |
Correct |
1366 ms |
45900 KB |
Output is correct |
91 |
Correct |
1512 ms |
46100 KB |
Output is correct |
92 |
Correct |
1353 ms |
45864 KB |
Output is correct |
93 |
Correct |
1038 ms |
53768 KB |
Output is correct |
94 |
Correct |
1287 ms |
54076 KB |
Output is correct |
95 |
Correct |
1070 ms |
53796 KB |
Output is correct |
96 |
Correct |
1099 ms |
53824 KB |
Output is correct |
97 |
Correct |
1702 ms |
53928 KB |
Output is correct |
98 |
Correct |
698 ms |
42504 KB |
Output is correct |
99 |
Correct |
1145 ms |
53936 KB |
Output is correct |
100 |
Correct |
1025 ms |
53696 KB |
Output is correct |
101 |
Correct |
975 ms |
47548 KB |
Output is correct |
102 |
Correct |
1056 ms |
53360 KB |
Output is correct |
103 |
Correct |
1568 ms |
53380 KB |
Output is correct |
104 |
Correct |
1037 ms |
53640 KB |
Output is correct |
105 |
Correct |
903 ms |
51468 KB |
Output is correct |
106 |
Correct |
814 ms |
52468 KB |
Output is correct |
107 |
Correct |
865 ms |
52640 KB |
Output is correct |
108 |
Correct |
856 ms |
52536 KB |
Output is correct |
109 |
Correct |
882 ms |
52492 KB |
Output is correct |
110 |
Correct |
887 ms |
52492 KB |
Output is correct |
111 |
Correct |
872 ms |
52484 KB |
Output is correct |
112 |
Correct |
901 ms |
52488 KB |
Output is correct |
113 |
Correct |
850 ms |
52560 KB |
Output is correct |
114 |
Correct |
787 ms |
52560 KB |
Output is correct |
115 |
Correct |
786 ms |
52488 KB |
Output is correct |
116 |
Correct |
777 ms |
52560 KB |
Output is correct |