#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846
int n, x[300005], y[300005], r[300005], sz;
int u[300005];
vector<pii> v;
vector<p3i> w;
vector<pair<int, vector<pair<int, vector<int> > > > > co;
void construct(){
int X, Y, R, I;
co.clear();
//cout << "!" << endl;
//cout << u[5] << ' ' <<w.size() << "%" << endl;
w.clear();
fox(l, n){
if (u[l] == 0)
w.pb(mp(mp(x[l]/sz, y[l]/sz), l));
}
sort(w.begin(), w.end());
fox(l, w.size()){
X = w[l].x.x; Y = w[l].x.y; I = w[l].y;
//if (u[I]) continue;
//cout << ' ' << X << ' ' << Y << ' ' << I << endl;
if (co.empty() || co.back().x != X) co.pb(mp(X, vector<pair<int, vector<int> > >()));
if (co.back().y.empty() || co.back().y.back().x != Y) co.back().y.pb(mp(Y, vector<int>()));
//if (I==5 || I == 10) cout << "*" << X << ' ' << Y << ' ' << co.back().y.back().y.size()<< endl;
co.back().y.back().y.pb(I);
//if (I == 5 || ) cout << co.back().x << ' ' << co.back().y.back().x << ' ' << endl;
}
}
void query(int P, int Cx, int Cy){
int I, I2, P2;
I = lb(co.begin(), co.end(), mp(Cx, vector<pair<int, vector<int> > >())) - co.begin();;
if (I == co.size() || co[I].x != Cx) return;
//if (P == 5) cout << "*";
I2 = lb(co[I].y.begin(), co[I].y.end(), mp(Cy, vector<int>())) - co[I].y.begin();
//if (P == 5) cout << I << ' ' << I2 << ' ' << co[I].y[I2].x << ' ' << Cy << endl;
if (I2 == co[I].y.size() || co[I].y[I2].x != Cy) return;
vector<int> tmp = co[I].y[I2].y;
//if (P == 5) cout << tmp.size() << endl;
fox(l, tmp.size()){
P2 = tmp[l];
//if (P == 5) cout << P2 << endl;
if (u[P2]) continue;
if (1LL*(x[P]-x[P2])*(x[P]-x[P2])+1LL*(y[P]-y[P2])*(y[P]-y[P2]) <= 1LL*(r[P]+r[P2])*(r[P]+r[P2])){
u[P2] = P+1;
}
}
}
int32_t main(){
scanf("%i", &n);
sz = 2000000001;
//co.pb(mp(0, vector<int>()));
//co[0].y.pb(mp(0, vector<int>()));
fox(l, n){
scanf("%i %i %i", &x[l], &y[l], &r[l]);
v.pb(mp(-r[l], l));
w.pb(mp(mp(x[l], y[l]), l));
//co[0].y[0].y.pb(l);
}
sort(v.begin(), v.end());
sort(w.begin(), w.end());
construct();
fox(l, v.size()){
v[l].x *= -1;
if (u[v[l].y]) continue;
while(v[l].x <= sz/4){
//cout << v[l].x << ' ' << sz << endl;
sz/=2;
construct();
}
//cout << v[l].y << ' ' << sz << endl;
//continue;
query(v[l].y, x[v[l].y]/sz-1, y[v[l].y]/sz+1);
query(v[l].y, x[v[l].y]/sz-1, y[v[l].y]/sz);
query(v[l].y, x[v[l].y]/sz-1, y[v[l].y]/sz-1);
query(v[l].y, x[v[l].y]/sz, y[v[l].y]/sz+1);
query(v[l].y, x[v[l].y]/sz, y[v[l].y]/sz);
query(v[l].y, x[v[l].y]/sz, y[v[l].y]/sz-1);
query(v[l].y, x[v[l].y]/sz+1, y[v[l].y]/sz+1);
query(v[l].y, x[v[l].y]/sz+1, y[v[l].y]/sz);
query(v[l].y, x[v[l].y]/sz+1, y[v[l].y]/sz-1);
}
fox(l, n){
printf("%i ", u[l]);
}
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
*/
Compilation message
circle_selection.cpp: In function 'void construct()':
circle_selection.cpp:23:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
circle_selection.cpp:51:7:
fox(l, w.size()){
~~~~~~~~~~~
circle_selection.cpp:51:3: note: in expansion of macro 'fox'
fox(l, w.size()){
^~~
circle_selection.cpp:41:13: warning: unused variable 'R' [-Wunused-variable]
int X, Y, R, I;
^
circle_selection.cpp: In function 'void query(int, int, int)':
circle_selection.cpp:65:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (I == co.size() || co[I].x != Cx) return;
~~^~~~~~~~~~~~
circle_selection.cpp:69:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (I2 == co[I].y.size() || co[I].y[I2].x != Cy) return;
~~~^~~~~~~~~~~~~~~~~
circle_selection.cpp:23:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
circle_selection.cpp:72:7:
fox(l, tmp.size()){
~~~~~~~~~~~~~
circle_selection.cpp:72:3: note: in expansion of macro 'fox'
fox(l, tmp.size()){
^~~
circle_selection.cpp: In function 'int32_t main()':
circle_selection.cpp:23:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
circle_selection.cpp:95:7:
fox(l, v.size()){
~~~~~~~~~~~
circle_selection.cpp:95:3: note: in expansion of macro 'fox'
fox(l, v.size()){
^~~
circle_selection.cpp:82:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i", &n);
~~~~~^~~~~~~~~~
circle_selection.cpp:87:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i %i %i", &x[l], &y[l], &r[l]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
6 ms |
640 KB |
Output is correct |
20 |
Correct |
7 ms |
640 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
27 ms |
1008 KB |
Output is correct |
23 |
Correct |
23 ms |
916 KB |
Output is correct |
24 |
Correct |
24 ms |
1152 KB |
Output is correct |
25 |
Correct |
31 ms |
1304 KB |
Output is correct |
26 |
Correct |
24 ms |
1152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
277 ms |
16212 KB |
Output is correct |
2 |
Correct |
270 ms |
16360 KB |
Output is correct |
3 |
Correct |
269 ms |
15940 KB |
Output is correct |
4 |
Correct |
229 ms |
16340 KB |
Output is correct |
5 |
Correct |
884 ms |
16240 KB |
Output is correct |
6 |
Correct |
1219 ms |
22776 KB |
Output is correct |
7 |
Correct |
934 ms |
16012 KB |
Output is correct |
8 |
Correct |
981 ms |
16620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
502 ms |
11276 KB |
Output is correct |
3 |
Correct |
1598 ms |
35516 KB |
Output is correct |
4 |
Correct |
1776 ms |
35456 KB |
Output is correct |
5 |
Correct |
1395 ms |
27248 KB |
Output is correct |
6 |
Correct |
607 ms |
13748 KB |
Output is correct |
7 |
Correct |
301 ms |
7304 KB |
Output is correct |
8 |
Correct |
65 ms |
2328 KB |
Output is correct |
9 |
Correct |
1651 ms |
32620 KB |
Output is correct |
10 |
Correct |
1287 ms |
25680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1928 ms |
36996 KB |
Output is correct |
2 |
Correct |
2811 ms |
49068 KB |
Output is correct |
3 |
Correct |
599 ms |
15868 KB |
Output is correct |
4 |
Correct |
1994 ms |
43720 KB |
Output is correct |
5 |
Correct |
2089 ms |
49392 KB |
Output is correct |
6 |
Correct |
518 ms |
15468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
6 ms |
640 KB |
Output is correct |
20 |
Correct |
7 ms |
640 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
27 ms |
1008 KB |
Output is correct |
23 |
Correct |
23 ms |
916 KB |
Output is correct |
24 |
Correct |
24 ms |
1152 KB |
Output is correct |
25 |
Correct |
31 ms |
1304 KB |
Output is correct |
26 |
Correct |
24 ms |
1152 KB |
Output is correct |
27 |
Correct |
14 ms |
1024 KB |
Output is correct |
28 |
Correct |
11 ms |
1024 KB |
Output is correct |
29 |
Correct |
10 ms |
1024 KB |
Output is correct |
30 |
Correct |
48 ms |
1664 KB |
Output is correct |
31 |
Correct |
58 ms |
1684 KB |
Output is correct |
32 |
Correct |
51 ms |
1912 KB |
Output is correct |
33 |
Correct |
83 ms |
5564 KB |
Output is correct |
34 |
Correct |
86 ms |
5384 KB |
Output is correct |
35 |
Correct |
113 ms |
5440 KB |
Output is correct |
36 |
Correct |
623 ms |
12304 KB |
Output is correct |
37 |
Correct |
628 ms |
12292 KB |
Output is correct |
38 |
Correct |
595 ms |
12008 KB |
Output is correct |
39 |
Correct |
445 ms |
7048 KB |
Output is correct |
40 |
Correct |
443 ms |
7048 KB |
Output is correct |
41 |
Correct |
414 ms |
7044 KB |
Output is correct |
42 |
Correct |
289 ms |
6280 KB |
Output is correct |
43 |
Correct |
618 ms |
14540 KB |
Output is correct |
44 |
Correct |
543 ms |
14420 KB |
Output is correct |
45 |
Correct |
543 ms |
14328 KB |
Output is correct |
46 |
Correct |
590 ms |
14436 KB |
Output is correct |
47 |
Correct |
571 ms |
14464 KB |
Output is correct |
48 |
Correct |
587 ms |
14612 KB |
Output is correct |
49 |
Correct |
574 ms |
14428 KB |
Output is correct |
50 |
Correct |
525 ms |
14460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
6 ms |
640 KB |
Output is correct |
20 |
Correct |
7 ms |
640 KB |
Output is correct |
21 |
Correct |
6 ms |
640 KB |
Output is correct |
22 |
Correct |
27 ms |
1008 KB |
Output is correct |
23 |
Correct |
23 ms |
916 KB |
Output is correct |
24 |
Correct |
24 ms |
1152 KB |
Output is correct |
25 |
Correct |
31 ms |
1304 KB |
Output is correct |
26 |
Correct |
24 ms |
1152 KB |
Output is correct |
27 |
Correct |
277 ms |
16212 KB |
Output is correct |
28 |
Correct |
270 ms |
16360 KB |
Output is correct |
29 |
Correct |
269 ms |
15940 KB |
Output is correct |
30 |
Correct |
229 ms |
16340 KB |
Output is correct |
31 |
Correct |
884 ms |
16240 KB |
Output is correct |
32 |
Correct |
1219 ms |
22776 KB |
Output is correct |
33 |
Correct |
934 ms |
16012 KB |
Output is correct |
34 |
Correct |
981 ms |
16620 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
502 ms |
11276 KB |
Output is correct |
37 |
Correct |
1598 ms |
35516 KB |
Output is correct |
38 |
Correct |
1776 ms |
35456 KB |
Output is correct |
39 |
Correct |
1395 ms |
27248 KB |
Output is correct |
40 |
Correct |
607 ms |
13748 KB |
Output is correct |
41 |
Correct |
301 ms |
7304 KB |
Output is correct |
42 |
Correct |
65 ms |
2328 KB |
Output is correct |
43 |
Correct |
1651 ms |
32620 KB |
Output is correct |
44 |
Correct |
1287 ms |
25680 KB |
Output is correct |
45 |
Correct |
1928 ms |
36996 KB |
Output is correct |
46 |
Correct |
2811 ms |
49068 KB |
Output is correct |
47 |
Correct |
599 ms |
15868 KB |
Output is correct |
48 |
Correct |
1994 ms |
43720 KB |
Output is correct |
49 |
Correct |
2089 ms |
49392 KB |
Output is correct |
50 |
Correct |
518 ms |
15468 KB |
Output is correct |
51 |
Correct |
14 ms |
1024 KB |
Output is correct |
52 |
Correct |
11 ms |
1024 KB |
Output is correct |
53 |
Correct |
10 ms |
1024 KB |
Output is correct |
54 |
Correct |
48 ms |
1664 KB |
Output is correct |
55 |
Correct |
58 ms |
1684 KB |
Output is correct |
56 |
Correct |
51 ms |
1912 KB |
Output is correct |
57 |
Correct |
83 ms |
5564 KB |
Output is correct |
58 |
Correct |
86 ms |
5384 KB |
Output is correct |
59 |
Correct |
113 ms |
5440 KB |
Output is correct |
60 |
Correct |
623 ms |
12304 KB |
Output is correct |
61 |
Correct |
628 ms |
12292 KB |
Output is correct |
62 |
Correct |
595 ms |
12008 KB |
Output is correct |
63 |
Correct |
445 ms |
7048 KB |
Output is correct |
64 |
Correct |
443 ms |
7048 KB |
Output is correct |
65 |
Correct |
414 ms |
7044 KB |
Output is correct |
66 |
Correct |
289 ms |
6280 KB |
Output is correct |
67 |
Correct |
618 ms |
14540 KB |
Output is correct |
68 |
Correct |
543 ms |
14420 KB |
Output is correct |
69 |
Correct |
543 ms |
14328 KB |
Output is correct |
70 |
Correct |
590 ms |
14436 KB |
Output is correct |
71 |
Correct |
571 ms |
14464 KB |
Output is correct |
72 |
Correct |
587 ms |
14612 KB |
Output is correct |
73 |
Correct |
574 ms |
14428 KB |
Output is correct |
74 |
Correct |
525 ms |
14460 KB |
Output is correct |
75 |
Correct |
253 ms |
15964 KB |
Output is correct |
76 |
Correct |
330 ms |
16280 KB |
Output is correct |
77 |
Correct |
299 ms |
16236 KB |
Output is correct |
78 |
Correct |
276 ms |
15976 KB |
Output is correct |
79 |
Correct |
404 ms |
16200 KB |
Output is correct |
80 |
Correct |
258 ms |
16052 KB |
Output is correct |
81 |
Correct |
1903 ms |
35584 KB |
Output is correct |
82 |
Correct |
1703 ms |
35244 KB |
Output is correct |
83 |
Correct |
1710 ms |
39528 KB |
Output is correct |
84 |
Correct |
1788 ms |
34880 KB |
Output is correct |
85 |
Correct |
1968 ms |
35908 KB |
Output is correct |
86 |
Correct |
1680 ms |
38896 KB |
Output is correct |
87 |
Correct |
1766 ms |
32520 KB |
Output is correct |
88 |
Correct |
1431 ms |
20840 KB |
Output is correct |
89 |
Correct |
1589 ms |
20472 KB |
Output is correct |
90 |
Correct |
1349 ms |
20712 KB |
Output is correct |
91 |
Correct |
1373 ms |
20720 KB |
Output is correct |
92 |
Correct |
1429 ms |
20600 KB |
Output is correct |
93 |
Correct |
1841 ms |
48380 KB |
Output is correct |
94 |
Correct |
1964 ms |
35700 KB |
Output is correct |
95 |
Correct |
2047 ms |
48252 KB |
Output is correct |
96 |
Correct |
1856 ms |
43788 KB |
Output is correct |
97 |
Correct |
2100 ms |
33808 KB |
Output is correct |
98 |
Correct |
1266 ms |
19880 KB |
Output is correct |
99 |
Correct |
2116 ms |
46664 KB |
Output is correct |
100 |
Correct |
2448 ms |
47584 KB |
Output is correct |
101 |
Correct |
1696 ms |
23616 KB |
Output is correct |
102 |
Correct |
1961 ms |
47484 KB |
Output is correct |
103 |
Correct |
1860 ms |
29676 KB |
Output is correct |
104 |
Correct |
2035 ms |
47432 KB |
Output is correct |
105 |
Correct |
996 ms |
16876 KB |
Output is correct |
106 |
Correct |
1681 ms |
34412 KB |
Output is correct |
107 |
Correct |
1554 ms |
34356 KB |
Output is correct |
108 |
Correct |
1622 ms |
34424 KB |
Output is correct |
109 |
Correct |
1634 ms |
34188 KB |
Output is correct |
110 |
Correct |
1733 ms |
34232 KB |
Output is correct |
111 |
Correct |
1576 ms |
34316 KB |
Output is correct |
112 |
Correct |
1763 ms |
34160 KB |
Output is correct |
113 |
Correct |
1707 ms |
34156 KB |
Output is correct |
114 |
Correct |
1683 ms |
34392 KB |
Output is correct |
115 |
Correct |
1514 ms |
34416 KB |
Output is correct |
116 |
Correct |
1514 ms |
38232 KB |
Output is correct |