/*
DavitMarg
In pr honky-tonk,
Down in Mexico
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <random>
#include <chrono>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 500005;
#define circle pair<pair<LL, LL>, pair<LL, int>>
#define X first.first
#define Y first.second
#define R second.first
#define I second.second
int n;
circle p[N];
LL rad;
vector<circle> g[N];
int ans[N];
bool intersect(circle a, circle b)
{
LL dx = a.X - b.X;
LL dy = a.Y - b.Y;
return (dx * dx) + (dy * dy) <= (a.R + b.R) * (a.R + b.R);
}
LL prm = 271;
LL H(pair<LL, LL> xy)
{
return ((prm * xy.first) + xy.second) % (N - 100);
}
void changeScale()
{
for (int i = 0; i < N - 100; i++)
g[i].clear();
for (int i = 1; i <= n; i++)
g[H(MP(p[i].X / rad, p[i].Y / rad))].push_back(p[i]);
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> p[i].X >> p[i].Y >> p[i].R;
p[i].X += mod;
p[i].Y += mod;
p[i].I = i;
rad = max(rad, p[i].R);
}
int cur = 0;
sort(p + 1, p + 1 + n, [](circle a, circle b) {
if(a.R != b.R)
return a.R > b.R;
return a.I < b.I;
});
changeScale();
for (int i = 1; i <= n; i++)
{
if (ans[p[i].I])
continue;
if (p[i].R * 2 < rad)
{
while (p[i].R * 2 < rad)
rad /= 2;
changeScale();
}
LL x = p[i].X / rad;
LL y = p[i].Y / rad;
for(int kx = x - 2; kx <= x + 2; kx++)
for (int ky = y - 2; ky <= y + 2; ky++)
{
vector<circle>& c = g[H(MP(kx, ky))];
for (int j = 0; j < c.size(); j++)
{
if (ans[c[j].I])
continue;
if(intersect(p[i], c[j]))
ans[c[j].I] = p[i].I;
}
}
}
for (int i = 1; i <= n; i++)
cout << ans[i] << " ";
cout << endl;
}
int main()
{
fastIO;
int T = 1;
//cin >> T;
while (T--)
{
solve();
}
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 solve()':
circle_selection.cpp:114:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<long long int, long long int>, std::pair<long long int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
114 | for (int j = 0; j < c.size(); j++)
| ~~^~~~~~~~~~
circle_selection.cpp:85:9: warning: unused variable 'cur' [-Wunused-variable]
85 | int cur = 0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
11988 KB |
Output is correct |
2 |
Correct |
7 ms |
11988 KB |
Output is correct |
3 |
Correct |
6 ms |
11988 KB |
Output is correct |
4 |
Correct |
6 ms |
11988 KB |
Output is correct |
5 |
Correct |
7 ms |
11988 KB |
Output is correct |
6 |
Correct |
6 ms |
11988 KB |
Output is correct |
7 |
Correct |
6 ms |
11988 KB |
Output is correct |
8 |
Correct |
7 ms |
12004 KB |
Output is correct |
9 |
Correct |
6 ms |
11988 KB |
Output is correct |
10 |
Correct |
6 ms |
11988 KB |
Output is correct |
11 |
Correct |
8 ms |
11988 KB |
Output is correct |
12 |
Correct |
8 ms |
12084 KB |
Output is correct |
13 |
Correct |
12 ms |
11988 KB |
Output is correct |
14 |
Correct |
9 ms |
12076 KB |
Output is correct |
15 |
Correct |
13 ms |
12116 KB |
Output is correct |
16 |
Correct |
8 ms |
12244 KB |
Output is correct |
17 |
Correct |
9 ms |
12056 KB |
Output is correct |
18 |
Correct |
6 ms |
12136 KB |
Output is correct |
19 |
Correct |
7 ms |
12628 KB |
Output is correct |
20 |
Correct |
11 ms |
12500 KB |
Output is correct |
21 |
Correct |
9 ms |
12884 KB |
Output is correct |
22 |
Correct |
24 ms |
14884 KB |
Output is correct |
23 |
Correct |
19 ms |
14676 KB |
Output is correct |
24 |
Correct |
21 ms |
15060 KB |
Output is correct |
25 |
Correct |
20 ms |
14932 KB |
Output is correct |
26 |
Correct |
20 ms |
14884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
145 ms |
46656 KB |
Output is correct |
2 |
Correct |
139 ms |
47440 KB |
Output is correct |
3 |
Correct |
121 ms |
34304 KB |
Output is correct |
4 |
Correct |
127 ms |
49568 KB |
Output is correct |
5 |
Correct |
304 ms |
93204 KB |
Output is correct |
6 |
Correct |
534 ms |
64808 KB |
Output is correct |
7 |
Correct |
419 ms |
89344 KB |
Output is correct |
8 |
Correct |
449 ms |
81012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
11988 KB |
Output is correct |
2 |
Correct |
314 ms |
43868 KB |
Output is correct |
3 |
Correct |
971 ms |
75828 KB |
Output is correct |
4 |
Correct |
964 ms |
82268 KB |
Output is correct |
5 |
Correct |
915 ms |
83384 KB |
Output is correct |
6 |
Correct |
287 ms |
49624 KB |
Output is correct |
7 |
Correct |
132 ms |
33996 KB |
Output is correct |
8 |
Correct |
32 ms |
16840 KB |
Output is correct |
9 |
Correct |
952 ms |
83944 KB |
Output is correct |
10 |
Correct |
592 ms |
72384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
440 ms |
37856 KB |
Output is correct |
2 |
Correct |
416 ms |
37808 KB |
Output is correct |
3 |
Correct |
151 ms |
38072 KB |
Output is correct |
4 |
Correct |
406 ms |
37924 KB |
Output is correct |
5 |
Correct |
422 ms |
37868 KB |
Output is correct |
6 |
Correct |
127 ms |
39628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
11988 KB |
Output is correct |
2 |
Correct |
7 ms |
11988 KB |
Output is correct |
3 |
Correct |
6 ms |
11988 KB |
Output is correct |
4 |
Correct |
6 ms |
11988 KB |
Output is correct |
5 |
Correct |
7 ms |
11988 KB |
Output is correct |
6 |
Correct |
6 ms |
11988 KB |
Output is correct |
7 |
Correct |
6 ms |
11988 KB |
Output is correct |
8 |
Correct |
7 ms |
12004 KB |
Output is correct |
9 |
Correct |
6 ms |
11988 KB |
Output is correct |
10 |
Correct |
6 ms |
11988 KB |
Output is correct |
11 |
Correct |
8 ms |
11988 KB |
Output is correct |
12 |
Correct |
8 ms |
12084 KB |
Output is correct |
13 |
Correct |
12 ms |
11988 KB |
Output is correct |
14 |
Correct |
9 ms |
12076 KB |
Output is correct |
15 |
Correct |
13 ms |
12116 KB |
Output is correct |
16 |
Correct |
8 ms |
12244 KB |
Output is correct |
17 |
Correct |
9 ms |
12056 KB |
Output is correct |
18 |
Correct |
6 ms |
12136 KB |
Output is correct |
19 |
Correct |
7 ms |
12628 KB |
Output is correct |
20 |
Correct |
11 ms |
12500 KB |
Output is correct |
21 |
Correct |
9 ms |
12884 KB |
Output is correct |
22 |
Correct |
24 ms |
14884 KB |
Output is correct |
23 |
Correct |
19 ms |
14676 KB |
Output is correct |
24 |
Correct |
21 ms |
15060 KB |
Output is correct |
25 |
Correct |
20 ms |
14932 KB |
Output is correct |
26 |
Correct |
20 ms |
14884 KB |
Output is correct |
27 |
Correct |
17 ms |
15444 KB |
Output is correct |
28 |
Correct |
9 ms |
12976 KB |
Output is correct |
29 |
Correct |
10 ms |
13012 KB |
Output is correct |
30 |
Correct |
33 ms |
17876 KB |
Output is correct |
31 |
Correct |
32 ms |
17492 KB |
Output is correct |
32 |
Correct |
34 ms |
17880 KB |
Output is correct |
33 |
Correct |
51 ms |
19408 KB |
Output is correct |
34 |
Correct |
46 ms |
20552 KB |
Output is correct |
35 |
Correct |
191 ms |
63812 KB |
Output is correct |
36 |
Correct |
271 ms |
41584 KB |
Output is correct |
37 |
Correct |
238 ms |
41568 KB |
Output is correct |
38 |
Correct |
246 ms |
42200 KB |
Output is correct |
39 |
Correct |
180 ms |
83528 KB |
Output is correct |
40 |
Correct |
178 ms |
83552 KB |
Output is correct |
41 |
Correct |
164 ms |
83244 KB |
Output is correct |
42 |
Correct |
48 ms |
20448 KB |
Output is correct |
43 |
Correct |
101 ms |
20720 KB |
Output is correct |
44 |
Correct |
95 ms |
20668 KB |
Output is correct |
45 |
Correct |
91 ms |
20652 KB |
Output is correct |
46 |
Correct |
91 ms |
20684 KB |
Output is correct |
47 |
Correct |
109 ms |
20656 KB |
Output is correct |
48 |
Correct |
88 ms |
20660 KB |
Output is correct |
49 |
Correct |
88 ms |
20648 KB |
Output is correct |
50 |
Correct |
92 ms |
20664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
11988 KB |
Output is correct |
2 |
Correct |
7 ms |
11988 KB |
Output is correct |
3 |
Correct |
6 ms |
11988 KB |
Output is correct |
4 |
Correct |
6 ms |
11988 KB |
Output is correct |
5 |
Correct |
7 ms |
11988 KB |
Output is correct |
6 |
Correct |
6 ms |
11988 KB |
Output is correct |
7 |
Correct |
6 ms |
11988 KB |
Output is correct |
8 |
Correct |
7 ms |
12004 KB |
Output is correct |
9 |
Correct |
6 ms |
11988 KB |
Output is correct |
10 |
Correct |
6 ms |
11988 KB |
Output is correct |
11 |
Correct |
8 ms |
11988 KB |
Output is correct |
12 |
Correct |
8 ms |
12084 KB |
Output is correct |
13 |
Correct |
12 ms |
11988 KB |
Output is correct |
14 |
Correct |
9 ms |
12076 KB |
Output is correct |
15 |
Correct |
13 ms |
12116 KB |
Output is correct |
16 |
Correct |
8 ms |
12244 KB |
Output is correct |
17 |
Correct |
9 ms |
12056 KB |
Output is correct |
18 |
Correct |
6 ms |
12136 KB |
Output is correct |
19 |
Correct |
7 ms |
12628 KB |
Output is correct |
20 |
Correct |
11 ms |
12500 KB |
Output is correct |
21 |
Correct |
9 ms |
12884 KB |
Output is correct |
22 |
Correct |
24 ms |
14884 KB |
Output is correct |
23 |
Correct |
19 ms |
14676 KB |
Output is correct |
24 |
Correct |
21 ms |
15060 KB |
Output is correct |
25 |
Correct |
20 ms |
14932 KB |
Output is correct |
26 |
Correct |
20 ms |
14884 KB |
Output is correct |
27 |
Correct |
145 ms |
46656 KB |
Output is correct |
28 |
Correct |
139 ms |
47440 KB |
Output is correct |
29 |
Correct |
121 ms |
34304 KB |
Output is correct |
30 |
Correct |
127 ms |
49568 KB |
Output is correct |
31 |
Correct |
304 ms |
93204 KB |
Output is correct |
32 |
Correct |
534 ms |
64808 KB |
Output is correct |
33 |
Correct |
419 ms |
89344 KB |
Output is correct |
34 |
Correct |
449 ms |
81012 KB |
Output is correct |
35 |
Correct |
9 ms |
11988 KB |
Output is correct |
36 |
Correct |
314 ms |
43868 KB |
Output is correct |
37 |
Correct |
971 ms |
75828 KB |
Output is correct |
38 |
Correct |
964 ms |
82268 KB |
Output is correct |
39 |
Correct |
915 ms |
83384 KB |
Output is correct |
40 |
Correct |
287 ms |
49624 KB |
Output is correct |
41 |
Correct |
132 ms |
33996 KB |
Output is correct |
42 |
Correct |
32 ms |
16840 KB |
Output is correct |
43 |
Correct |
952 ms |
83944 KB |
Output is correct |
44 |
Correct |
592 ms |
72384 KB |
Output is correct |
45 |
Correct |
440 ms |
37856 KB |
Output is correct |
46 |
Correct |
416 ms |
37808 KB |
Output is correct |
47 |
Correct |
151 ms |
38072 KB |
Output is correct |
48 |
Correct |
406 ms |
37924 KB |
Output is correct |
49 |
Correct |
422 ms |
37868 KB |
Output is correct |
50 |
Correct |
127 ms |
39628 KB |
Output is correct |
51 |
Correct |
17 ms |
15444 KB |
Output is correct |
52 |
Correct |
9 ms |
12976 KB |
Output is correct |
53 |
Correct |
10 ms |
13012 KB |
Output is correct |
54 |
Correct |
33 ms |
17876 KB |
Output is correct |
55 |
Correct |
32 ms |
17492 KB |
Output is correct |
56 |
Correct |
34 ms |
17880 KB |
Output is correct |
57 |
Correct |
51 ms |
19408 KB |
Output is correct |
58 |
Correct |
46 ms |
20552 KB |
Output is correct |
59 |
Correct |
191 ms |
63812 KB |
Output is correct |
60 |
Correct |
271 ms |
41584 KB |
Output is correct |
61 |
Correct |
238 ms |
41568 KB |
Output is correct |
62 |
Correct |
246 ms |
42200 KB |
Output is correct |
63 |
Correct |
180 ms |
83528 KB |
Output is correct |
64 |
Correct |
178 ms |
83552 KB |
Output is correct |
65 |
Correct |
164 ms |
83244 KB |
Output is correct |
66 |
Correct |
48 ms |
20448 KB |
Output is correct |
67 |
Correct |
101 ms |
20720 KB |
Output is correct |
68 |
Correct |
95 ms |
20668 KB |
Output is correct |
69 |
Correct |
91 ms |
20652 KB |
Output is correct |
70 |
Correct |
91 ms |
20684 KB |
Output is correct |
71 |
Correct |
109 ms |
20656 KB |
Output is correct |
72 |
Correct |
88 ms |
20660 KB |
Output is correct |
73 |
Correct |
88 ms |
20648 KB |
Output is correct |
74 |
Correct |
92 ms |
20664 KB |
Output is correct |
75 |
Correct |
431 ms |
157400 KB |
Output is correct |
76 |
Correct |
158 ms |
69784 KB |
Output is correct |
77 |
Correct |
139 ms |
44424 KB |
Output is correct |
78 |
Correct |
142 ms |
41260 KB |
Output is correct |
79 |
Correct |
597 ms |
150064 KB |
Output is correct |
80 |
Correct |
152 ms |
40284 KB |
Output is correct |
81 |
Correct |
924 ms |
80348 KB |
Output is correct |
82 |
Correct |
954 ms |
81364 KB |
Output is correct |
83 |
Correct |
959 ms |
80448 KB |
Output is correct |
84 |
Correct |
888 ms |
81176 KB |
Output is correct |
85 |
Correct |
958 ms |
81388 KB |
Output is correct |
86 |
Correct |
956 ms |
81404 KB |
Output is correct |
87 |
Correct |
990 ms |
82204 KB |
Output is correct |
88 |
Correct |
586 ms |
226616 KB |
Output is correct |
89 |
Correct |
571 ms |
219460 KB |
Output is correct |
90 |
Correct |
559 ms |
223052 KB |
Output is correct |
91 |
Correct |
578 ms |
220596 KB |
Output is correct |
92 |
Correct |
566 ms |
220368 KB |
Output is correct |
93 |
Correct |
653 ms |
62472 KB |
Output is correct |
94 |
Correct |
697 ms |
68572 KB |
Output is correct |
95 |
Correct |
637 ms |
62408 KB |
Output is correct |
96 |
Correct |
657 ms |
65732 KB |
Output is correct |
97 |
Correct |
678 ms |
62384 KB |
Output is correct |
98 |
Correct |
608 ms |
71720 KB |
Output is correct |
99 |
Correct |
720 ms |
68608 KB |
Output is correct |
100 |
Correct |
573 ms |
52744 KB |
Output is correct |
101 |
Correct |
612 ms |
73076 KB |
Output is correct |
102 |
Correct |
720 ms |
68308 KB |
Output is correct |
103 |
Correct |
668 ms |
68392 KB |
Output is correct |
104 |
Correct |
709 ms |
68396 KB |
Output is correct |
105 |
Correct |
319 ms |
42184 KB |
Output is correct |
106 |
Correct |
377 ms |
44284 KB |
Output is correct |
107 |
Correct |
427 ms |
44316 KB |
Output is correct |
108 |
Correct |
478 ms |
44404 KB |
Output is correct |
109 |
Correct |
451 ms |
44344 KB |
Output is correct |
110 |
Correct |
459 ms |
44260 KB |
Output is correct |
111 |
Correct |
447 ms |
44288 KB |
Output is correct |
112 |
Correct |
393 ms |
44316 KB |
Output is correct |
113 |
Correct |
380 ms |
44272 KB |
Output is correct |
114 |
Correct |
357 ms |
44176 KB |
Output is correct |
115 |
Correct |
454 ms |
44120 KB |
Output is correct |
116 |
Correct |
459 ms |
44284 KB |
Output is correct |