/*input
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
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k) for(int i = j ; i < k ; ++i)
#define RREP(i,j,k) for(int i = j ; i >=k ; --i)
#define A first
#define B second
#define mp make_pair
#define pb emplace_back
#define PII pair<int , int>
#define MEM(i,j) memset(i , j , sizeof i)
#define ALL(i) i.begin() , i.end()
#define DBGG(i,j) cout << i << " " << j << endl
#define DB4(i,j,k,l) cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 300090
#define getchar getchar_unlocked
#define INF 2e9
cc_hash_table<int_fast64_t , int> cc;
vector<PII> v[MAX];
vector<int> las;
int_fast64_t R = 1e14;
int n , pos;
int x[MAX] , y[MAX] , r[MAX] , sol[MAX] , ans[MAX];
inline int_fast64_t trs(int a , int b){ return 1LL * a * 1000000009 + b; }
inline int cmp(int a , int b){ return mp(r[a] , -a) > mp(r[b] , -b); }
inline int tch(int a , int b){
int_fast64_t val = 1LL * (x[a] - x[b]) * (x[a] - x[b]) + 1LL * (y[a] - y[b]) * (y[a] - y[b]);
return (val <= 1LL * (r[a] + r[b]) * (r[a] + r[b]));
}
inline int rit(){
int val = 0 , f = 1;
char c = getchar();
while(!isdigit(c)){
if(c == '-') f = -1;
c = getchar();
}
while(isdigit(c)){
val = (val << 1) + (val << 3) + (c & 15);
c = getchar();
}
return val * f;
}
int32_t main(){
n = rit();
REP(i , 1 , n + 1) x[i] = rit() , y[i] = rit() , r[i] = rit();
// REP(i , 1 , n + 1) cin >> x[i] >> y[i] >> r[i];
REP(i , 1 , n + 1) sol[i] = i;
sort(sol + 1 , sol + 1 + n , cmp);
// REP(idx , 1 , n + 1){ int i = sol[idx];
// if(ans[i]) continue;
// REP(j , 1 , n + 1) if(ans[j] == 0 && tch(i , j)) ans[j] = i;
// }
REP(i , 1 , n + 1) las.pb(i);
int del = 1000000;
REP(idx , 1 , n + 1){ int i = sol[idx];
if(ans[i]) continue;
// DBGG("solve = " , i);
if(R / 5 > r[i] && del > 1000){
del = 0;
cc.clear();
R = r[i];
vector<int> nw;
for(auto j : las){
if(ans[j]) continue;
nw.pb(j);
int xx = x[j] / R , yy = y[j] / R;
if(cc.find(trs(xx , yy)) == cc.end()){
v[pos].clear();
v[pos].pb(0 , 1);
cc[trs(xx , yy)] = pos ++;
if(pos == MAX) pos = 0;
}
v[cc[trs(xx , yy)]].pb(j , v[cc[trs(xx , yy)]].size() + 1);
}
swap(nw , las);
}
int xx = x[i] / R , yy = y[i] / R;
REP(ii , xx - 2 , xx + 3) REP(jj , yy - 2 , yy + 3){
if(cc.find(trs(ii , jj)) != cc.end()){
int id = cc[trs(ii , jj)] , pre = 0;
while(v[id][pre].B < v[id].size()){
int now = v[id][pre].B;
if(tch(i , v[id][now].A)){
ans[v[id][now].A] = i;
del ++;
v[id][pre].B = v[id][now].B;
}
else pre = now;
}
// for(auto to : v[id]){
// if(ans[to.A] == 0 && tch(i , to.A)) ans[to.A] = i;
// }
}
}
}
REP(i , 1 , n + 1) printf("%d " , ans[i]);
puts("");
return 0;
}
// 7 2 7 4 5 6 7 7 4 7 6
Compilation message
circle_selection.cpp: In function 'int32_t main()':
circle_selection.cpp:102:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(v[id][pre].B < v[id].size()){
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
Output is correct |
2 |
Correct |
7 ms |
7524 KB |
Output is correct |
3 |
Correct |
7 ms |
7536 KB |
Output is correct |
4 |
Correct |
7 ms |
7656 KB |
Output is correct |
5 |
Correct |
7 ms |
7656 KB |
Output is correct |
6 |
Correct |
8 ms |
7680 KB |
Output is correct |
7 |
Correct |
7 ms |
7680 KB |
Output is correct |
8 |
Correct |
7 ms |
7700 KB |
Output is correct |
9 |
Correct |
7 ms |
7700 KB |
Output is correct |
10 |
Correct |
7 ms |
7700 KB |
Output is correct |
11 |
Correct |
7 ms |
7704 KB |
Output is correct |
12 |
Correct |
7 ms |
7704 KB |
Output is correct |
13 |
Correct |
7 ms |
7704 KB |
Output is correct |
14 |
Correct |
7 ms |
7704 KB |
Output is correct |
15 |
Correct |
7 ms |
7704 KB |
Output is correct |
16 |
Correct |
8 ms |
7704 KB |
Output is correct |
17 |
Correct |
8 ms |
7704 KB |
Output is correct |
18 |
Correct |
8 ms |
7704 KB |
Output is correct |
19 |
Correct |
9 ms |
7800 KB |
Output is correct |
20 |
Correct |
9 ms |
7864 KB |
Output is correct |
21 |
Correct |
9 ms |
7924 KB |
Output is correct |
22 |
Correct |
16 ms |
8292 KB |
Output is correct |
23 |
Correct |
12 ms |
8340 KB |
Output is correct |
24 |
Correct |
13 ms |
8356 KB |
Output is correct |
25 |
Correct |
13 ms |
8356 KB |
Output is correct |
26 |
Correct |
13 ms |
8356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
145 ms |
19648 KB |
Output is correct |
2 |
Correct |
146 ms |
19972 KB |
Output is correct |
3 |
Correct |
141 ms |
20128 KB |
Output is correct |
4 |
Correct |
145 ms |
21392 KB |
Output is correct |
5 |
Correct |
164 ms |
21392 KB |
Output is correct |
6 |
Correct |
449 ms |
32216 KB |
Output is correct |
7 |
Correct |
190 ms |
32216 KB |
Output is correct |
8 |
Correct |
235 ms |
32216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
32216 KB |
Output is correct |
2 |
Correct |
182 ms |
32216 KB |
Output is correct |
3 |
Correct |
851 ms |
45924 KB |
Output is correct |
4 |
Correct |
750 ms |
46052 KB |
Output is correct |
5 |
Correct |
833 ms |
46052 KB |
Output is correct |
6 |
Correct |
244 ms |
46052 KB |
Output is correct |
7 |
Correct |
110 ms |
46052 KB |
Output is correct |
8 |
Correct |
24 ms |
46052 KB |
Output is correct |
9 |
Correct |
901 ms |
46052 KB |
Output is correct |
10 |
Correct |
648 ms |
46052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
625 ms |
46052 KB |
Output is correct |
2 |
Correct |
622 ms |
46052 KB |
Output is correct |
3 |
Correct |
319 ms |
46052 KB |
Output is correct |
4 |
Correct |
608 ms |
46052 KB |
Output is correct |
5 |
Correct |
684 ms |
46052 KB |
Output is correct |
6 |
Correct |
183 ms |
46052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
Output is correct |
2 |
Correct |
7 ms |
7524 KB |
Output is correct |
3 |
Correct |
7 ms |
7536 KB |
Output is correct |
4 |
Correct |
7 ms |
7656 KB |
Output is correct |
5 |
Correct |
7 ms |
7656 KB |
Output is correct |
6 |
Correct |
8 ms |
7680 KB |
Output is correct |
7 |
Correct |
7 ms |
7680 KB |
Output is correct |
8 |
Correct |
7 ms |
7700 KB |
Output is correct |
9 |
Correct |
7 ms |
7700 KB |
Output is correct |
10 |
Correct |
7 ms |
7700 KB |
Output is correct |
11 |
Correct |
7 ms |
7704 KB |
Output is correct |
12 |
Correct |
7 ms |
7704 KB |
Output is correct |
13 |
Correct |
7 ms |
7704 KB |
Output is correct |
14 |
Correct |
7 ms |
7704 KB |
Output is correct |
15 |
Correct |
7 ms |
7704 KB |
Output is correct |
16 |
Correct |
8 ms |
7704 KB |
Output is correct |
17 |
Correct |
8 ms |
7704 KB |
Output is correct |
18 |
Correct |
8 ms |
7704 KB |
Output is correct |
19 |
Correct |
9 ms |
7800 KB |
Output is correct |
20 |
Correct |
9 ms |
7864 KB |
Output is correct |
21 |
Correct |
9 ms |
7924 KB |
Output is correct |
22 |
Correct |
16 ms |
8292 KB |
Output is correct |
23 |
Correct |
12 ms |
8340 KB |
Output is correct |
24 |
Correct |
13 ms |
8356 KB |
Output is correct |
25 |
Correct |
13 ms |
8356 KB |
Output is correct |
26 |
Correct |
13 ms |
8356 KB |
Output is correct |
27 |
Correct |
12 ms |
46052 KB |
Output is correct |
28 |
Correct |
11 ms |
46052 KB |
Output is correct |
29 |
Correct |
11 ms |
46052 KB |
Output is correct |
30 |
Correct |
20 ms |
46052 KB |
Output is correct |
31 |
Correct |
19 ms |
46052 KB |
Output is correct |
32 |
Correct |
19 ms |
46052 KB |
Output is correct |
33 |
Correct |
73 ms |
46052 KB |
Output is correct |
34 |
Correct |
51 ms |
46052 KB |
Output is correct |
35 |
Correct |
51 ms |
46052 KB |
Output is correct |
36 |
Correct |
209 ms |
46052 KB |
Output is correct |
37 |
Correct |
215 ms |
46052 KB |
Output is correct |
38 |
Correct |
232 ms |
46052 KB |
Output is correct |
39 |
Correct |
233 ms |
46052 KB |
Output is correct |
40 |
Correct |
244 ms |
46052 KB |
Output is correct |
41 |
Correct |
254 ms |
46052 KB |
Output is correct |
42 |
Correct |
125 ms |
46052 KB |
Output is correct |
43 |
Correct |
144 ms |
46052 KB |
Output is correct |
44 |
Correct |
157 ms |
46052 KB |
Output is correct |
45 |
Correct |
143 ms |
46052 KB |
Output is correct |
46 |
Correct |
141 ms |
46052 KB |
Output is correct |
47 |
Correct |
191 ms |
46052 KB |
Output is correct |
48 |
Correct |
153 ms |
46052 KB |
Output is correct |
49 |
Correct |
145 ms |
46052 KB |
Output is correct |
50 |
Correct |
178 ms |
46052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7416 KB |
Output is correct |
2 |
Correct |
7 ms |
7524 KB |
Output is correct |
3 |
Correct |
7 ms |
7536 KB |
Output is correct |
4 |
Correct |
7 ms |
7656 KB |
Output is correct |
5 |
Correct |
7 ms |
7656 KB |
Output is correct |
6 |
Correct |
8 ms |
7680 KB |
Output is correct |
7 |
Correct |
7 ms |
7680 KB |
Output is correct |
8 |
Correct |
7 ms |
7700 KB |
Output is correct |
9 |
Correct |
7 ms |
7700 KB |
Output is correct |
10 |
Correct |
7 ms |
7700 KB |
Output is correct |
11 |
Correct |
7 ms |
7704 KB |
Output is correct |
12 |
Correct |
7 ms |
7704 KB |
Output is correct |
13 |
Correct |
7 ms |
7704 KB |
Output is correct |
14 |
Correct |
7 ms |
7704 KB |
Output is correct |
15 |
Correct |
7 ms |
7704 KB |
Output is correct |
16 |
Correct |
8 ms |
7704 KB |
Output is correct |
17 |
Correct |
8 ms |
7704 KB |
Output is correct |
18 |
Correct |
8 ms |
7704 KB |
Output is correct |
19 |
Correct |
9 ms |
7800 KB |
Output is correct |
20 |
Correct |
9 ms |
7864 KB |
Output is correct |
21 |
Correct |
9 ms |
7924 KB |
Output is correct |
22 |
Correct |
16 ms |
8292 KB |
Output is correct |
23 |
Correct |
12 ms |
8340 KB |
Output is correct |
24 |
Correct |
13 ms |
8356 KB |
Output is correct |
25 |
Correct |
13 ms |
8356 KB |
Output is correct |
26 |
Correct |
13 ms |
8356 KB |
Output is correct |
27 |
Correct |
145 ms |
19648 KB |
Output is correct |
28 |
Correct |
146 ms |
19972 KB |
Output is correct |
29 |
Correct |
141 ms |
20128 KB |
Output is correct |
30 |
Correct |
145 ms |
21392 KB |
Output is correct |
31 |
Correct |
164 ms |
21392 KB |
Output is correct |
32 |
Correct |
449 ms |
32216 KB |
Output is correct |
33 |
Correct |
190 ms |
32216 KB |
Output is correct |
34 |
Correct |
235 ms |
32216 KB |
Output is correct |
35 |
Correct |
8 ms |
32216 KB |
Output is correct |
36 |
Correct |
182 ms |
32216 KB |
Output is correct |
37 |
Correct |
851 ms |
45924 KB |
Output is correct |
38 |
Correct |
750 ms |
46052 KB |
Output is correct |
39 |
Correct |
833 ms |
46052 KB |
Output is correct |
40 |
Correct |
244 ms |
46052 KB |
Output is correct |
41 |
Correct |
110 ms |
46052 KB |
Output is correct |
42 |
Correct |
24 ms |
46052 KB |
Output is correct |
43 |
Correct |
901 ms |
46052 KB |
Output is correct |
44 |
Correct |
648 ms |
46052 KB |
Output is correct |
45 |
Correct |
625 ms |
46052 KB |
Output is correct |
46 |
Correct |
622 ms |
46052 KB |
Output is correct |
47 |
Correct |
319 ms |
46052 KB |
Output is correct |
48 |
Correct |
608 ms |
46052 KB |
Output is correct |
49 |
Correct |
684 ms |
46052 KB |
Output is correct |
50 |
Correct |
183 ms |
46052 KB |
Output is correct |
51 |
Correct |
12 ms |
46052 KB |
Output is correct |
52 |
Correct |
11 ms |
46052 KB |
Output is correct |
53 |
Correct |
11 ms |
46052 KB |
Output is correct |
54 |
Correct |
20 ms |
46052 KB |
Output is correct |
55 |
Correct |
19 ms |
46052 KB |
Output is correct |
56 |
Correct |
19 ms |
46052 KB |
Output is correct |
57 |
Correct |
73 ms |
46052 KB |
Output is correct |
58 |
Correct |
51 ms |
46052 KB |
Output is correct |
59 |
Correct |
51 ms |
46052 KB |
Output is correct |
60 |
Correct |
209 ms |
46052 KB |
Output is correct |
61 |
Correct |
215 ms |
46052 KB |
Output is correct |
62 |
Correct |
232 ms |
46052 KB |
Output is correct |
63 |
Correct |
233 ms |
46052 KB |
Output is correct |
64 |
Correct |
244 ms |
46052 KB |
Output is correct |
65 |
Correct |
254 ms |
46052 KB |
Output is correct |
66 |
Correct |
125 ms |
46052 KB |
Output is correct |
67 |
Correct |
144 ms |
46052 KB |
Output is correct |
68 |
Correct |
157 ms |
46052 KB |
Output is correct |
69 |
Correct |
143 ms |
46052 KB |
Output is correct |
70 |
Correct |
141 ms |
46052 KB |
Output is correct |
71 |
Correct |
191 ms |
46052 KB |
Output is correct |
72 |
Correct |
153 ms |
46052 KB |
Output is correct |
73 |
Correct |
145 ms |
46052 KB |
Output is correct |
74 |
Correct |
178 ms |
46052 KB |
Output is correct |
75 |
Correct |
168 ms |
46052 KB |
Output is correct |
76 |
Correct |
174 ms |
46052 KB |
Output is correct |
77 |
Correct |
168 ms |
46052 KB |
Output is correct |
78 |
Correct |
166 ms |
46052 KB |
Output is correct |
79 |
Correct |
203 ms |
46052 KB |
Output is correct |
80 |
Correct |
145 ms |
46052 KB |
Output is correct |
81 |
Correct |
806 ms |
46052 KB |
Output is correct |
82 |
Correct |
873 ms |
46052 KB |
Output is correct |
83 |
Correct |
997 ms |
46052 KB |
Output is correct |
84 |
Correct |
873 ms |
46052 KB |
Output is correct |
85 |
Correct |
969 ms |
46052 KB |
Output is correct |
86 |
Correct |
883 ms |
46052 KB |
Output is correct |
87 |
Correct |
929 ms |
46052 KB |
Output is correct |
88 |
Correct |
878 ms |
46052 KB |
Output is correct |
89 |
Correct |
1018 ms |
46052 KB |
Output is correct |
90 |
Correct |
808 ms |
46052 KB |
Output is correct |
91 |
Correct |
872 ms |
46052 KB |
Output is correct |
92 |
Correct |
860 ms |
46052 KB |
Output is correct |
93 |
Correct |
786 ms |
46052 KB |
Output is correct |
94 |
Correct |
775 ms |
46052 KB |
Output is correct |
95 |
Correct |
704 ms |
46052 KB |
Output is correct |
96 |
Correct |
714 ms |
46052 KB |
Output is correct |
97 |
Correct |
674 ms |
46052 KB |
Output is correct |
98 |
Correct |
587 ms |
46052 KB |
Output is correct |
99 |
Correct |
705 ms |
46052 KB |
Output is correct |
100 |
Correct |
603 ms |
46052 KB |
Output is correct |
101 |
Correct |
712 ms |
46052 KB |
Output is correct |
102 |
Correct |
753 ms |
46052 KB |
Output is correct |
103 |
Correct |
884 ms |
46052 KB |
Output is correct |
104 |
Correct |
812 ms |
46052 KB |
Output is correct |
105 |
Correct |
713 ms |
46052 KB |
Output is correct |
106 |
Correct |
599 ms |
46052 KB |
Output is correct |
107 |
Correct |
556 ms |
46052 KB |
Output is correct |
108 |
Correct |
772 ms |
46052 KB |
Output is correct |
109 |
Correct |
604 ms |
46052 KB |
Output is correct |
110 |
Correct |
658 ms |
46052 KB |
Output is correct |
111 |
Correct |
605 ms |
46052 KB |
Output is correct |
112 |
Correct |
573 ms |
46052 KB |
Output is correct |
113 |
Correct |
586 ms |
46052 KB |
Output is correct |
114 |
Correct |
552 ms |
46052 KB |
Output is correct |
115 |
Correct |
574 ms |
46052 KB |
Output is correct |
116 |
Correct |
601 ms |
46052 KB |
Output is correct |