#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;
const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=300010, LOG=20;
int n, m, k, u, v, x, y, t, a, b, sz;
int X[MAXN], Y[MAXN], R[MAXN], P[MAXN], L;
int ans[MAXN];
pii shit[MAXN];
vector<int> mp[MAXN];
bool check(int i, int j){
ll dx=X[i]-X[j], dy=Y[i]-Y[j], r=R[i]+R[j];
return dx*dx+dy*dy<=r*r;
}
int gt(pii p){
return lower_bound(shit, shit+sz, p)-shit;
}
void Build(){
for (int i=0; i<sz; i++) mp[i].clear();
sz=0;
for (int i=1; i<=n; i++) if (!ans[i]) shit[sz++]={X[i]/L, Y[i]/L};
sort(shit, shit+sz);
sz=unique(shit, shit+sz)-shit;
for (int i=1; i<=n; i++) if (!ans[i]) mp[gt({X[i]/L, Y[i]/L})].pb(i);
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cin>>n;
for (int i=1; i<=n; i++) cin>>X[i]>>Y[i]>>R[i], P[i]=i;
sort(P+1, P+n+1, [](int i, int j){
return pii(R[i], -i)>pii(R[j], -j);
});
L=R[P[1]];
Build();
// for (int i=0; i<sz; i++) debugp(shit[i])
for (int i=1; i<=n; i++){
int id=P[i];
if (ans[id]) continue ;
if (R[id]<.75*L) L=R[id], Build();
int x=X[id]/L, y=Y[id]/L;
for (int xx=x-2; xx<=x+2; xx++)
for (int yy=y-2; yy<=y+2; yy++){
int pos=gt({xx, yy});
if (pos==sz || shit[pos]!=pii(xx, yy)) continue ;
vector<int> vec=mp[pos], v2;
for (int j:vec){
if (check(id, j)) ans[j]=id;
else v2.pb(j);
}
mp[pos]=v2;
}
}
for (int i=1; i<=n; i++) cout<<ans[i]<<' ';
return 0;
}
/*
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7424 KB |
Output is correct |
2 |
Correct |
9 ms |
7424 KB |
Output is correct |
3 |
Correct |
9 ms |
7424 KB |
Output is correct |
4 |
Correct |
8 ms |
7424 KB |
Output is correct |
5 |
Correct |
10 ms |
7424 KB |
Output is correct |
6 |
Correct |
9 ms |
7424 KB |
Output is correct |
7 |
Correct |
8 ms |
7424 KB |
Output is correct |
8 |
Correct |
10 ms |
7424 KB |
Output is correct |
9 |
Correct |
9 ms |
7424 KB |
Output is correct |
10 |
Correct |
9 ms |
7424 KB |
Output is correct |
11 |
Correct |
9 ms |
7424 KB |
Output is correct |
12 |
Correct |
9 ms |
7424 KB |
Output is correct |
13 |
Correct |
9 ms |
7424 KB |
Output is correct |
14 |
Correct |
9 ms |
7424 KB |
Output is correct |
15 |
Correct |
9 ms |
7424 KB |
Output is correct |
16 |
Correct |
9 ms |
7424 KB |
Output is correct |
17 |
Correct |
9 ms |
7424 KB |
Output is correct |
18 |
Correct |
11 ms |
7424 KB |
Output is correct |
19 |
Correct |
12 ms |
7808 KB |
Output is correct |
20 |
Correct |
12 ms |
7808 KB |
Output is correct |
21 |
Correct |
12 ms |
7808 KB |
Output is correct |
22 |
Correct |
22 ms |
7936 KB |
Output is correct |
23 |
Correct |
25 ms |
7808 KB |
Output is correct |
24 |
Correct |
23 ms |
7936 KB |
Output is correct |
25 |
Correct |
22 ms |
7936 KB |
Output is correct |
26 |
Correct |
23 ms |
7936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
208 ms |
19536 KB |
Output is correct |
2 |
Correct |
222 ms |
20724 KB |
Output is correct |
3 |
Correct |
210 ms |
19352 KB |
Output is correct |
4 |
Correct |
201 ms |
19556 KB |
Output is correct |
5 |
Correct |
275 ms |
19960 KB |
Output is correct |
6 |
Correct |
650 ms |
22776 KB |
Output is correct |
7 |
Correct |
327 ms |
20728 KB |
Output is correct |
8 |
Correct |
394 ms |
20984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7424 KB |
Output is correct |
2 |
Correct |
426 ms |
14328 KB |
Output is correct |
3 |
Correct |
1503 ms |
27752 KB |
Output is correct |
4 |
Correct |
1474 ms |
27624 KB |
Output is correct |
5 |
Correct |
1568 ms |
26092 KB |
Output is correct |
6 |
Correct |
570 ms |
17220 KB |
Output is correct |
7 |
Correct |
269 ms |
12896 KB |
Output is correct |
8 |
Correct |
45 ms |
8824 KB |
Output is correct |
9 |
Correct |
1753 ms |
27452 KB |
Output is correct |
10 |
Correct |
1376 ms |
33340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1084 ms |
27512 KB |
Output is correct |
2 |
Correct |
844 ms |
27480 KB |
Output is correct |
3 |
Correct |
385 ms |
20984 KB |
Output is correct |
4 |
Correct |
876 ms |
27384 KB |
Output is correct |
5 |
Correct |
911 ms |
27440 KB |
Output is correct |
6 |
Correct |
303 ms |
19704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7424 KB |
Output is correct |
2 |
Correct |
9 ms |
7424 KB |
Output is correct |
3 |
Correct |
9 ms |
7424 KB |
Output is correct |
4 |
Correct |
8 ms |
7424 KB |
Output is correct |
5 |
Correct |
10 ms |
7424 KB |
Output is correct |
6 |
Correct |
9 ms |
7424 KB |
Output is correct |
7 |
Correct |
8 ms |
7424 KB |
Output is correct |
8 |
Correct |
10 ms |
7424 KB |
Output is correct |
9 |
Correct |
9 ms |
7424 KB |
Output is correct |
10 |
Correct |
9 ms |
7424 KB |
Output is correct |
11 |
Correct |
9 ms |
7424 KB |
Output is correct |
12 |
Correct |
9 ms |
7424 KB |
Output is correct |
13 |
Correct |
9 ms |
7424 KB |
Output is correct |
14 |
Correct |
9 ms |
7424 KB |
Output is correct |
15 |
Correct |
9 ms |
7424 KB |
Output is correct |
16 |
Correct |
9 ms |
7424 KB |
Output is correct |
17 |
Correct |
9 ms |
7424 KB |
Output is correct |
18 |
Correct |
11 ms |
7424 KB |
Output is correct |
19 |
Correct |
12 ms |
7808 KB |
Output is correct |
20 |
Correct |
12 ms |
7808 KB |
Output is correct |
21 |
Correct |
12 ms |
7808 KB |
Output is correct |
22 |
Correct |
22 ms |
7936 KB |
Output is correct |
23 |
Correct |
25 ms |
7808 KB |
Output is correct |
24 |
Correct |
23 ms |
7936 KB |
Output is correct |
25 |
Correct |
22 ms |
7936 KB |
Output is correct |
26 |
Correct |
23 ms |
7936 KB |
Output is correct |
27 |
Correct |
17 ms |
8192 KB |
Output is correct |
28 |
Correct |
17 ms |
8064 KB |
Output is correct |
29 |
Correct |
16 ms |
8064 KB |
Output is correct |
30 |
Correct |
44 ms |
8320 KB |
Output is correct |
31 |
Correct |
39 ms |
8320 KB |
Output is correct |
32 |
Correct |
40 ms |
8320 KB |
Output is correct |
33 |
Correct |
84 ms |
11868 KB |
Output is correct |
34 |
Correct |
83 ms |
11836 KB |
Output is correct |
35 |
Correct |
89 ms |
11864 KB |
Output is correct |
36 |
Correct |
398 ms |
14460 KB |
Output is correct |
37 |
Correct |
400 ms |
14584 KB |
Output is correct |
38 |
Correct |
394 ms |
14584 KB |
Output is correct |
39 |
Correct |
414 ms |
15368 KB |
Output is correct |
40 |
Correct |
437 ms |
15380 KB |
Output is correct |
41 |
Correct |
413 ms |
15880 KB |
Output is correct |
42 |
Correct |
217 ms |
14488 KB |
Output is correct |
43 |
Correct |
246 ms |
14456 KB |
Output is correct |
44 |
Correct |
290 ms |
14456 KB |
Output is correct |
45 |
Correct |
250 ms |
14456 KB |
Output is correct |
46 |
Correct |
262 ms |
14456 KB |
Output is correct |
47 |
Correct |
253 ms |
14456 KB |
Output is correct |
48 |
Correct |
248 ms |
14456 KB |
Output is correct |
49 |
Correct |
247 ms |
14456 KB |
Output is correct |
50 |
Correct |
253 ms |
14504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7424 KB |
Output is correct |
2 |
Correct |
9 ms |
7424 KB |
Output is correct |
3 |
Correct |
9 ms |
7424 KB |
Output is correct |
4 |
Correct |
8 ms |
7424 KB |
Output is correct |
5 |
Correct |
10 ms |
7424 KB |
Output is correct |
6 |
Correct |
9 ms |
7424 KB |
Output is correct |
7 |
Correct |
8 ms |
7424 KB |
Output is correct |
8 |
Correct |
10 ms |
7424 KB |
Output is correct |
9 |
Correct |
9 ms |
7424 KB |
Output is correct |
10 |
Correct |
9 ms |
7424 KB |
Output is correct |
11 |
Correct |
9 ms |
7424 KB |
Output is correct |
12 |
Correct |
9 ms |
7424 KB |
Output is correct |
13 |
Correct |
9 ms |
7424 KB |
Output is correct |
14 |
Correct |
9 ms |
7424 KB |
Output is correct |
15 |
Correct |
9 ms |
7424 KB |
Output is correct |
16 |
Correct |
9 ms |
7424 KB |
Output is correct |
17 |
Correct |
9 ms |
7424 KB |
Output is correct |
18 |
Correct |
11 ms |
7424 KB |
Output is correct |
19 |
Correct |
12 ms |
7808 KB |
Output is correct |
20 |
Correct |
12 ms |
7808 KB |
Output is correct |
21 |
Correct |
12 ms |
7808 KB |
Output is correct |
22 |
Correct |
22 ms |
7936 KB |
Output is correct |
23 |
Correct |
25 ms |
7808 KB |
Output is correct |
24 |
Correct |
23 ms |
7936 KB |
Output is correct |
25 |
Correct |
22 ms |
7936 KB |
Output is correct |
26 |
Correct |
23 ms |
7936 KB |
Output is correct |
27 |
Correct |
208 ms |
19536 KB |
Output is correct |
28 |
Correct |
222 ms |
20724 KB |
Output is correct |
29 |
Correct |
210 ms |
19352 KB |
Output is correct |
30 |
Correct |
201 ms |
19556 KB |
Output is correct |
31 |
Correct |
275 ms |
19960 KB |
Output is correct |
32 |
Correct |
650 ms |
22776 KB |
Output is correct |
33 |
Correct |
327 ms |
20728 KB |
Output is correct |
34 |
Correct |
394 ms |
20984 KB |
Output is correct |
35 |
Correct |
9 ms |
7424 KB |
Output is correct |
36 |
Correct |
426 ms |
14328 KB |
Output is correct |
37 |
Correct |
1503 ms |
27752 KB |
Output is correct |
38 |
Correct |
1474 ms |
27624 KB |
Output is correct |
39 |
Correct |
1568 ms |
26092 KB |
Output is correct |
40 |
Correct |
570 ms |
17220 KB |
Output is correct |
41 |
Correct |
269 ms |
12896 KB |
Output is correct |
42 |
Correct |
45 ms |
8824 KB |
Output is correct |
43 |
Correct |
1753 ms |
27452 KB |
Output is correct |
44 |
Correct |
1376 ms |
33340 KB |
Output is correct |
45 |
Correct |
1084 ms |
27512 KB |
Output is correct |
46 |
Correct |
844 ms |
27480 KB |
Output is correct |
47 |
Correct |
385 ms |
20984 KB |
Output is correct |
48 |
Correct |
876 ms |
27384 KB |
Output is correct |
49 |
Correct |
911 ms |
27440 KB |
Output is correct |
50 |
Correct |
303 ms |
19704 KB |
Output is correct |
51 |
Correct |
17 ms |
8192 KB |
Output is correct |
52 |
Correct |
17 ms |
8064 KB |
Output is correct |
53 |
Correct |
16 ms |
8064 KB |
Output is correct |
54 |
Correct |
44 ms |
8320 KB |
Output is correct |
55 |
Correct |
39 ms |
8320 KB |
Output is correct |
56 |
Correct |
40 ms |
8320 KB |
Output is correct |
57 |
Correct |
84 ms |
11868 KB |
Output is correct |
58 |
Correct |
83 ms |
11836 KB |
Output is correct |
59 |
Correct |
89 ms |
11864 KB |
Output is correct |
60 |
Correct |
398 ms |
14460 KB |
Output is correct |
61 |
Correct |
400 ms |
14584 KB |
Output is correct |
62 |
Correct |
394 ms |
14584 KB |
Output is correct |
63 |
Correct |
414 ms |
15368 KB |
Output is correct |
64 |
Correct |
437 ms |
15380 KB |
Output is correct |
65 |
Correct |
413 ms |
15880 KB |
Output is correct |
66 |
Correct |
217 ms |
14488 KB |
Output is correct |
67 |
Correct |
246 ms |
14456 KB |
Output is correct |
68 |
Correct |
290 ms |
14456 KB |
Output is correct |
69 |
Correct |
250 ms |
14456 KB |
Output is correct |
70 |
Correct |
262 ms |
14456 KB |
Output is correct |
71 |
Correct |
253 ms |
14456 KB |
Output is correct |
72 |
Correct |
248 ms |
14456 KB |
Output is correct |
73 |
Correct |
247 ms |
14456 KB |
Output is correct |
74 |
Correct |
253 ms |
14504 KB |
Output is correct |
75 |
Correct |
277 ms |
28332 KB |
Output is correct |
76 |
Correct |
239 ms |
28108 KB |
Output is correct |
77 |
Correct |
232 ms |
28476 KB |
Output is correct |
78 |
Correct |
230 ms |
27988 KB |
Output is correct |
79 |
Correct |
312 ms |
28408 KB |
Output is correct |
80 |
Correct |
241 ms |
27728 KB |
Output is correct |
81 |
Correct |
1457 ms |
35124 KB |
Output is correct |
82 |
Correct |
1452 ms |
34840 KB |
Output is correct |
83 |
Correct |
1417 ms |
34744 KB |
Output is correct |
84 |
Correct |
1491 ms |
35308 KB |
Output is correct |
85 |
Correct |
1435 ms |
35000 KB |
Output is correct |
86 |
Correct |
1491 ms |
35068 KB |
Output is correct |
87 |
Correct |
1559 ms |
34936 KB |
Output is correct |
88 |
Correct |
1285 ms |
33268 KB |
Output is correct |
89 |
Correct |
1401 ms |
35440 KB |
Output is correct |
90 |
Correct |
1343 ms |
35404 KB |
Output is correct |
91 |
Correct |
1306 ms |
33380 KB |
Output is correct |
92 |
Correct |
1182 ms |
33280 KB |
Output is correct |
93 |
Correct |
1132 ms |
34040 KB |
Output is correct |
94 |
Correct |
1256 ms |
34312 KB |
Output is correct |
95 |
Correct |
1161 ms |
34040 KB |
Output is correct |
96 |
Correct |
1182 ms |
34092 KB |
Output is correct |
97 |
Correct |
1437 ms |
33912 KB |
Output is correct |
98 |
Correct |
803 ms |
30840 KB |
Output is correct |
99 |
Correct |
1236 ms |
34040 KB |
Output is correct |
100 |
Correct |
971 ms |
33808 KB |
Output is correct |
101 |
Correct |
1063 ms |
32380 KB |
Output is correct |
102 |
Correct |
1238 ms |
33784 KB |
Output is correct |
103 |
Correct |
1425 ms |
33852 KB |
Output is correct |
104 |
Correct |
1261 ms |
33720 KB |
Output is correct |
105 |
Correct |
734 ms |
31636 KB |
Output is correct |
106 |
Correct |
874 ms |
34296 KB |
Output is correct |
107 |
Correct |
853 ms |
34116 KB |
Output is correct |
108 |
Correct |
856 ms |
34144 KB |
Output is correct |
109 |
Correct |
859 ms |
34296 KB |
Output is correct |
110 |
Correct |
825 ms |
34200 KB |
Output is correct |
111 |
Correct |
851 ms |
34168 KB |
Output is correct |
112 |
Correct |
819 ms |
34380 KB |
Output is correct |
113 |
Correct |
844 ms |
34304 KB |
Output is correct |
114 |
Correct |
827 ms |
34168 KB |
Output is correct |
115 |
Correct |
830 ms |
34424 KB |
Output is correct |
116 |
Correct |
787 ms |
34136 KB |
Output is correct |