#include <bits/stdc++.h>
#define int long long
using namespace std;
array<int, 3> A[300005];
const int INF = 2e9 + 1;
unordered_map<int, vector<int>> M[31];
int pw2[33];
int ans[300005];
int dx[9] = {-1,-1,-1,0,0,0,1,1,1};
int dy[9] = {-1,0,1,-1,0,1,-1,0,1};
bool inter(int a, int b) {
int k = 1LL * (A[a][0]-A[b][0])*(A[a][0]-A[b][0]);
k += 1LL * (A[a][1]-A[b][1])*(A[a][1]-A[b][1]);
return k <= 1LL*(A[a][2]+A[b][2])*(A[a][2]+A[b][2]);
}
bool vis[33];
signed main() {
cin.sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int i, j;
pw2[0] = 1;
for(i=1;i<33;i++) pw2[i] = pw2[i-1] * 2;
int N;
cin >> N;
for(i=0;i<N;i++) cin >> A[i][0] >> A[i][1] >> A[i][2];
for(i=0;i<N;i++) {
A[i][0] += (int)1e9;
A[i][1] += (int)1e9;
}
vector<array<int, 2>> V;
for(i=0;i<N;i++) V.push_back({A[i][2], i});
sort(V.begin(),V.end(), [](array<int, 2> x, array<int,2> y) {
if(x[0]==y[0]) return x[1]<y[1];
return x[0]>y[0];
});
for(i=0;i<N;i++) ans[i] = -1;
for(i=0;i<N;i++) {
int id = V[i][1];
if(ans[id]!=-1) continue;
ans[id] = id;
int k = 0;
while(2*A[id][2]>pw2[k+1]) k++;
if(!vis[k]) {
for(j=0;j<N;j++) {
if(ans[j]!=-1) continue;
M[k][INF*(A[j][0]/pw2[k+1])+A[j][1]/pw2[k+1]].push_back(j);
}
vis[k] = true;
}
//cout << id << ' ' << k << '\n';
int x1 = A[id][0]/pw2[k+1], x2 = A[id][1]/pw2[k+1];
for(j=0;j<9;j++) {
for(int v : M[k][INF*(x1+dx[j])+x2+dy[j]]) {
//cout << k << ' ' << x1+dx[j] << ' ' << x2 + dy[j] << ' ' << v << '\n';
if(ans[v]!=-1||inter(v, id)) {
if(ans[v]==-1) ans[v] = id;
}
}
}
}
for(i=0;i<N;i++) cout << ans[i] + 1 << ' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
868 KB |
Output is correct |
20 |
Correct |
3 ms |
912 KB |
Output is correct |
21 |
Correct |
3 ms |
860 KB |
Output is correct |
22 |
Correct |
11 ms |
4016 KB |
Output is correct |
23 |
Correct |
12 ms |
4412 KB |
Output is correct |
24 |
Correct |
13 ms |
4064 KB |
Output is correct |
25 |
Correct |
11 ms |
4132 KB |
Output is correct |
26 |
Correct |
13 ms |
4412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
138 ms |
26900 KB |
Output is correct |
2 |
Correct |
140 ms |
27820 KB |
Output is correct |
3 |
Correct |
139 ms |
29092 KB |
Output is correct |
4 |
Correct |
140 ms |
29736 KB |
Output is correct |
5 |
Correct |
169 ms |
25808 KB |
Output is correct |
6 |
Correct |
427 ms |
67628 KB |
Output is correct |
7 |
Correct |
203 ms |
29880 KB |
Output is correct |
8 |
Correct |
211 ms |
35136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
434 ms |
79196 KB |
Output is correct |
3 |
Correct |
1656 ms |
223996 KB |
Output is correct |
4 |
Correct |
1619 ms |
225232 KB |
Output is correct |
5 |
Correct |
1313 ms |
178308 KB |
Output is correct |
6 |
Correct |
450 ms |
67308 KB |
Output is correct |
7 |
Correct |
183 ms |
34624 KB |
Output is correct |
8 |
Correct |
24 ms |
6972 KB |
Output is correct |
9 |
Correct |
1833 ms |
236668 KB |
Output is correct |
10 |
Correct |
1037 ms |
122844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1229 ms |
183448 KB |
Output is correct |
2 |
Correct |
1247 ms |
182692 KB |
Output is correct |
3 |
Correct |
203 ms |
29792 KB |
Output is correct |
4 |
Correct |
1233 ms |
183108 KB |
Output is correct |
5 |
Correct |
1198 ms |
183260 KB |
Output is correct |
6 |
Correct |
166 ms |
28716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
868 KB |
Output is correct |
20 |
Correct |
3 ms |
912 KB |
Output is correct |
21 |
Correct |
3 ms |
860 KB |
Output is correct |
22 |
Correct |
11 ms |
4016 KB |
Output is correct |
23 |
Correct |
12 ms |
4412 KB |
Output is correct |
24 |
Correct |
13 ms |
4064 KB |
Output is correct |
25 |
Correct |
11 ms |
4132 KB |
Output is correct |
26 |
Correct |
13 ms |
4412 KB |
Output is correct |
27 |
Correct |
6 ms |
1368 KB |
Output is correct |
28 |
Correct |
5 ms |
1264 KB |
Output is correct |
29 |
Correct |
5 ms |
1368 KB |
Output is correct |
30 |
Correct |
24 ms |
7736 KB |
Output is correct |
31 |
Correct |
27 ms |
8564 KB |
Output is correct |
32 |
Correct |
23 ms |
7604 KB |
Output is correct |
33 |
Correct |
49 ms |
10444 KB |
Output is correct |
34 |
Correct |
51 ms |
10560 KB |
Output is correct |
35 |
Correct |
60 ms |
10244 KB |
Output is correct |
36 |
Correct |
443 ms |
80888 KB |
Output is correct |
37 |
Correct |
446 ms |
79332 KB |
Output is correct |
38 |
Correct |
447 ms |
81336 KB |
Output is correct |
39 |
Correct |
176 ms |
28728 KB |
Output is correct |
40 |
Correct |
177 ms |
28768 KB |
Output is correct |
41 |
Correct |
190 ms |
28752 KB |
Output is correct |
42 |
Correct |
63 ms |
9932 KB |
Output is correct |
43 |
Correct |
337 ms |
61052 KB |
Output is correct |
44 |
Correct |
348 ms |
60900 KB |
Output is correct |
45 |
Correct |
353 ms |
60992 KB |
Output is correct |
46 |
Correct |
419 ms |
61016 KB |
Output is correct |
47 |
Correct |
355 ms |
61052 KB |
Output is correct |
48 |
Correct |
356 ms |
60992 KB |
Output is correct |
49 |
Correct |
334 ms |
60996 KB |
Output is correct |
50 |
Correct |
384 ms |
60996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
868 KB |
Output is correct |
20 |
Correct |
3 ms |
912 KB |
Output is correct |
21 |
Correct |
3 ms |
860 KB |
Output is correct |
22 |
Correct |
11 ms |
4016 KB |
Output is correct |
23 |
Correct |
12 ms |
4412 KB |
Output is correct |
24 |
Correct |
13 ms |
4064 KB |
Output is correct |
25 |
Correct |
11 ms |
4132 KB |
Output is correct |
26 |
Correct |
13 ms |
4412 KB |
Output is correct |
27 |
Correct |
138 ms |
26900 KB |
Output is correct |
28 |
Correct |
140 ms |
27820 KB |
Output is correct |
29 |
Correct |
139 ms |
29092 KB |
Output is correct |
30 |
Correct |
140 ms |
29736 KB |
Output is correct |
31 |
Correct |
169 ms |
25808 KB |
Output is correct |
32 |
Correct |
427 ms |
67628 KB |
Output is correct |
33 |
Correct |
203 ms |
29880 KB |
Output is correct |
34 |
Correct |
211 ms |
35136 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
434 ms |
79196 KB |
Output is correct |
37 |
Correct |
1656 ms |
223996 KB |
Output is correct |
38 |
Correct |
1619 ms |
225232 KB |
Output is correct |
39 |
Correct |
1313 ms |
178308 KB |
Output is correct |
40 |
Correct |
450 ms |
67308 KB |
Output is correct |
41 |
Correct |
183 ms |
34624 KB |
Output is correct |
42 |
Correct |
24 ms |
6972 KB |
Output is correct |
43 |
Correct |
1833 ms |
236668 KB |
Output is correct |
44 |
Correct |
1037 ms |
122844 KB |
Output is correct |
45 |
Correct |
1229 ms |
183448 KB |
Output is correct |
46 |
Correct |
1247 ms |
182692 KB |
Output is correct |
47 |
Correct |
203 ms |
29792 KB |
Output is correct |
48 |
Correct |
1233 ms |
183108 KB |
Output is correct |
49 |
Correct |
1198 ms |
183260 KB |
Output is correct |
50 |
Correct |
166 ms |
28716 KB |
Output is correct |
51 |
Correct |
6 ms |
1368 KB |
Output is correct |
52 |
Correct |
5 ms |
1264 KB |
Output is correct |
53 |
Correct |
5 ms |
1368 KB |
Output is correct |
54 |
Correct |
24 ms |
7736 KB |
Output is correct |
55 |
Correct |
27 ms |
8564 KB |
Output is correct |
56 |
Correct |
23 ms |
7604 KB |
Output is correct |
57 |
Correct |
49 ms |
10444 KB |
Output is correct |
58 |
Correct |
51 ms |
10560 KB |
Output is correct |
59 |
Correct |
60 ms |
10244 KB |
Output is correct |
60 |
Correct |
443 ms |
80888 KB |
Output is correct |
61 |
Correct |
446 ms |
79332 KB |
Output is correct |
62 |
Correct |
447 ms |
81336 KB |
Output is correct |
63 |
Correct |
176 ms |
28728 KB |
Output is correct |
64 |
Correct |
177 ms |
28768 KB |
Output is correct |
65 |
Correct |
190 ms |
28752 KB |
Output is correct |
66 |
Correct |
63 ms |
9932 KB |
Output is correct |
67 |
Correct |
337 ms |
61052 KB |
Output is correct |
68 |
Correct |
348 ms |
60900 KB |
Output is correct |
69 |
Correct |
353 ms |
60992 KB |
Output is correct |
70 |
Correct |
419 ms |
61016 KB |
Output is correct |
71 |
Correct |
355 ms |
61052 KB |
Output is correct |
72 |
Correct |
356 ms |
60992 KB |
Output is correct |
73 |
Correct |
334 ms |
60996 KB |
Output is correct |
74 |
Correct |
384 ms |
60996 KB |
Output is correct |
75 |
Correct |
166 ms |
31924 KB |
Output is correct |
76 |
Correct |
163 ms |
28896 KB |
Output is correct |
77 |
Correct |
147 ms |
29120 KB |
Output is correct |
78 |
Correct |
150 ms |
31660 KB |
Output is correct |
79 |
Correct |
214 ms |
29432 KB |
Output is correct |
80 |
Correct |
147 ms |
31660 KB |
Output is correct |
81 |
Correct |
1737 ms |
238172 KB |
Output is correct |
82 |
Correct |
1713 ms |
218820 KB |
Output is correct |
83 |
Correct |
1651 ms |
226424 KB |
Output is correct |
84 |
Correct |
1622 ms |
222180 KB |
Output is correct |
85 |
Correct |
1615 ms |
222928 KB |
Output is correct |
86 |
Correct |
1605 ms |
219600 KB |
Output is correct |
87 |
Correct |
1664 ms |
213952 KB |
Output is correct |
88 |
Correct |
781 ms |
84048 KB |
Output is correct |
89 |
Correct |
774 ms |
84148 KB |
Output is correct |
90 |
Correct |
769 ms |
84108 KB |
Output is correct |
91 |
Correct |
755 ms |
84032 KB |
Output is correct |
92 |
Correct |
737 ms |
84068 KB |
Output is correct |
93 |
Correct |
1699 ms |
227036 KB |
Output is correct |
94 |
Correct |
1549 ms |
213952 KB |
Output is correct |
95 |
Correct |
1580 ms |
225480 KB |
Output is correct |
96 |
Correct |
1733 ms |
224372 KB |
Output is correct |
97 |
Correct |
1692 ms |
220132 KB |
Output is correct |
98 |
Correct |
515 ms |
78800 KB |
Output is correct |
99 |
Correct |
1787 ms |
222156 KB |
Output is correct |
100 |
Correct |
1782 ms |
217160 KB |
Output is correct |
101 |
Correct |
675 ms |
89792 KB |
Output is correct |
102 |
Correct |
1564 ms |
205680 KB |
Output is correct |
103 |
Correct |
1626 ms |
213084 KB |
Output is correct |
104 |
Correct |
1678 ms |
218392 KB |
Output is correct |
105 |
Correct |
288 ms |
29636 KB |
Output is correct |
106 |
Correct |
841 ms |
137228 KB |
Output is correct |
107 |
Correct |
941 ms |
137348 KB |
Output is correct |
108 |
Correct |
1113 ms |
137268 KB |
Output is correct |
109 |
Correct |
885 ms |
137428 KB |
Output is correct |
110 |
Correct |
1605 ms |
137248 KB |
Output is correct |
111 |
Correct |
1246 ms |
137328 KB |
Output is correct |
112 |
Correct |
925 ms |
137392 KB |
Output is correct |
113 |
Correct |
1143 ms |
137260 KB |
Output is correct |
114 |
Correct |
986 ms |
137332 KB |
Output is correct |
115 |
Correct |
911 ms |
137324 KB |
Output is correct |
116 |
Correct |
924 ms |
137132 KB |
Output is correct |