/*
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[N];
map<pair<LL, LL>, vector<circle>> g[35];
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);
}
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[0] = max(rad[0], p[i].R);
}
for (int k = 0; k < 33; k++)
{
if (rad[k] == 0)
break;
for (int i = 1; i <= n; i++)
g[k][MP(p[i].X / rad[k], p[i].Y / rad[k])].push_back(p[i]);
rad[k + 1] = rad[k] / 2;
}
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;
});
for (int i = 1; i <= n; i++)
{
if (ans[p[i].I])
continue;
while (p[i].R * 2 < rad[cur])
cur++;
LL x = p[i].X / rad[cur];
LL y = p[i].Y / rad[cur];
for(int kx = x - 2; kx <= x + 2; kx++)
for (int ky = y - 2; ky <= y + 2; ky++)
{
if (g[cur].find(MP(kx, ky)) == g[cur].end())
continue;
vector<circle>& c = g[cur][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:101: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]
101 | for (int j = 0; j < c.size(); j++)
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
8 ms |
3584 KB |
Output is correct |
17 |
Correct |
6 ms |
3284 KB |
Output is correct |
18 |
Correct |
6 ms |
3412 KB |
Output is correct |
19 |
Correct |
37 ms |
15792 KB |
Output is correct |
20 |
Correct |
30 ms |
13316 KB |
Output is correct |
21 |
Correct |
42 ms |
16492 KB |
Output is correct |
22 |
Correct |
26 ms |
9228 KB |
Output is correct |
23 |
Correct |
27 ms |
8660 KB |
Output is correct |
24 |
Correct |
36 ms |
9916 KB |
Output is correct |
25 |
Correct |
24 ms |
8640 KB |
Output is correct |
26 |
Correct |
28 ms |
9868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3099 ms |
634372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1160 ms |
242580 KB |
Output is correct |
3 |
Execution timed out |
3037 ms |
655996 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3108 ms |
499792 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
8 ms |
3584 KB |
Output is correct |
17 |
Correct |
6 ms |
3284 KB |
Output is correct |
18 |
Correct |
6 ms |
3412 KB |
Output is correct |
19 |
Correct |
37 ms |
15792 KB |
Output is correct |
20 |
Correct |
30 ms |
13316 KB |
Output is correct |
21 |
Correct |
42 ms |
16492 KB |
Output is correct |
22 |
Correct |
26 ms |
9228 KB |
Output is correct |
23 |
Correct |
27 ms |
8660 KB |
Output is correct |
24 |
Correct |
36 ms |
9916 KB |
Output is correct |
25 |
Correct |
24 ms |
8640 KB |
Output is correct |
26 |
Correct |
28 ms |
9868 KB |
Output is correct |
27 |
Correct |
101 ms |
31532 KB |
Output is correct |
28 |
Correct |
96 ms |
29736 KB |
Output is correct |
29 |
Correct |
96 ms |
31240 KB |
Output is correct |
30 |
Correct |
68 ms |
18508 KB |
Output is correct |
31 |
Correct |
72 ms |
19724 KB |
Output is correct |
32 |
Correct |
62 ms |
18480 KB |
Output is correct |
33 |
Correct |
1320 ms |
299732 KB |
Output is correct |
34 |
Correct |
1328 ms |
304248 KB |
Output is correct |
35 |
Correct |
1397 ms |
289812 KB |
Output is correct |
36 |
Correct |
912 ms |
180860 KB |
Output is correct |
37 |
Correct |
895 ms |
180884 KB |
Output is correct |
38 |
Correct |
918 ms |
193388 KB |
Output is correct |
39 |
Correct |
453 ms |
117448 KB |
Output is correct |
40 |
Correct |
450 ms |
119876 KB |
Output is correct |
41 |
Correct |
452 ms |
118768 KB |
Output is correct |
42 |
Correct |
513 ms |
105560 KB |
Output is correct |
43 |
Correct |
613 ms |
130468 KB |
Output is correct |
44 |
Correct |
642 ms |
131824 KB |
Output is correct |
45 |
Correct |
667 ms |
131816 KB |
Output is correct |
46 |
Correct |
654 ms |
131916 KB |
Output is correct |
47 |
Correct |
616 ms |
131836 KB |
Output is correct |
48 |
Correct |
653 ms |
131828 KB |
Output is correct |
49 |
Correct |
626 ms |
131896 KB |
Output is correct |
50 |
Correct |
630 ms |
131848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
8 ms |
3584 KB |
Output is correct |
17 |
Correct |
6 ms |
3284 KB |
Output is correct |
18 |
Correct |
6 ms |
3412 KB |
Output is correct |
19 |
Correct |
37 ms |
15792 KB |
Output is correct |
20 |
Correct |
30 ms |
13316 KB |
Output is correct |
21 |
Correct |
42 ms |
16492 KB |
Output is correct |
22 |
Correct |
26 ms |
9228 KB |
Output is correct |
23 |
Correct |
27 ms |
8660 KB |
Output is correct |
24 |
Correct |
36 ms |
9916 KB |
Output is correct |
25 |
Correct |
24 ms |
8640 KB |
Output is correct |
26 |
Correct |
28 ms |
9868 KB |
Output is correct |
27 |
Execution timed out |
3099 ms |
634372 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |