#include <bits/stdc++.h>
using namespace std;
using ll = long long;
namespace Cercus {
unordered_map<int, unordered_map<int, vector<int> > > cont;
int lastr = 2e9 + 5;
vector<tuple<int, int, int> > v;
vector<int> sorted, elim;
int xx[2], yy[2], rr[2];
ll p2(ll x) { return x * x; }
bool check(int i, int j) {
tie(rr[0], xx[0], yy[0]) = v[i];
tie(rr[1], xx[1], yy[1]) = v[j];
return p2(xx[0] - xx[1]) + p2(yy[0] - yy[1]) <= p2(rr[0] + rr[1]);
}
void redocontainer(int nr) {
lastr = nr;
for(int i = 0, x, y, r; i < v.size(); i++) {
if(elim[i] == -1) {
tie(r, x, y) = v[i];
cont[x / (2 * nr)][y / (2 * nr)].push_back(i);
}
}
}
void gothrough(int ind) {
if(elim[ind] != -1)
return;
int x, y, r;
tie(r, x, y) = v[ind];
if(r <= lastr / 2)
redocontainer(r);
x /= 2 * lastr;
y /= 2 * lastr;
//cerr << "--" << lastr << "--\n";
for(int i = x - 1; i <= x + 1; i++) {
if(cont.find(i) == cont.end())
continue;
for(int j = y - 1; j <= y + 1; j++) {
if(cont[i].find(j) == cont[i].end())
continue;
for(int ptr = 0, z; ptr < cont[i][j].size(); ptr++) {
z = cont[i][j][ptr];
//cerr << ind + 1<< "--> " << z + 1 << ' ';
if(check(z, ind)) {
//cerr << "YES";
elim[z] = ind;
swap(cont[i][j].back(), cont[i][j][ptr]);
cont[i][j].pop_back();
ptr--;
}
//cerr << '\n';
}
}
}
}
void read() {
int n;
cin >> n;
v.resize(n);
sorted.resize(n);
elim.resize(n);
for(auto &[r, x, y] : v)
cin >> x >> y >> r;
for(int i = 0; i < n; i++)
sorted[i] = i, elim[i] = -1;
sort(sorted.begin(), sorted.end(), [&](auto x, auto y) { return get<0>(v[x]) > get<0>(v[y]) || (get<0>(v[x]) == get<0>(v[y]) && x < y);});
}
void startelim() {
for(auto z : sorted)
gothrough(z);
}
void print() {
for(auto x : elim)
cout << x + 1 << ' ';
cout << '\n';
return;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
Cercus::read();
Cercus::startelim();
Cercus::print();
}
Compilation message
circle_selection.cpp: In function 'void Cercus::redocontainer(int)':
circle_selection.cpp:20:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for(int i = 0, x, y, r; i < v.size(); i++) {
| ~~^~~~~~~~~~
circle_selection.cpp: In function 'void Cercus::gothrough(int)':
circle_selection.cpp:43:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for(int ptr = 0, z; ptr < cont[i][j].size(); ptr++) {
| ~~~~^~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
324 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 |
316 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
372 KB |
Output is correct |
19 |
Correct |
7 ms |
588 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
21 |
Correct |
4 ms |
596 KB |
Output is correct |
22 |
Correct |
10 ms |
2504 KB |
Output is correct |
23 |
Correct |
11 ms |
1736 KB |
Output is correct |
24 |
Correct |
12 ms |
2644 KB |
Output is correct |
25 |
Correct |
12 ms |
3232 KB |
Output is correct |
26 |
Correct |
11 ms |
2700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
204 ms |
16412 KB |
Output is correct |
2 |
Correct |
214 ms |
16188 KB |
Output is correct |
3 |
Correct |
238 ms |
15936 KB |
Output is correct |
4 |
Correct |
214 ms |
16260 KB |
Output is correct |
5 |
Correct |
293 ms |
16564 KB |
Output is correct |
6 |
Correct |
651 ms |
57756 KB |
Output is correct |
7 |
Correct |
318 ms |
20196 KB |
Output is correct |
8 |
Correct |
387 ms |
26924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
410 ms |
27656 KB |
Output is correct |
3 |
Correct |
1419 ms |
82464 KB |
Output is correct |
4 |
Correct |
1486 ms |
83016 KB |
Output is correct |
5 |
Correct |
1247 ms |
75960 KB |
Output is correct |
6 |
Correct |
526 ms |
27336 KB |
Output is correct |
7 |
Correct |
172 ms |
13864 KB |
Output is correct |
8 |
Correct |
32 ms |
3924 KB |
Output is correct |
9 |
Correct |
1594 ms |
101932 KB |
Output is correct |
10 |
Correct |
1179 ms |
55188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1039 ms |
47676 KB |
Output is correct |
2 |
Correct |
742 ms |
97596 KB |
Output is correct |
3 |
Correct |
310 ms |
20208 KB |
Output is correct |
4 |
Correct |
736 ms |
90056 KB |
Output is correct |
5 |
Correct |
734 ms |
94564 KB |
Output is correct |
6 |
Correct |
250 ms |
18672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
324 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 |
316 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
372 KB |
Output is correct |
19 |
Correct |
7 ms |
588 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
21 |
Correct |
4 ms |
596 KB |
Output is correct |
22 |
Correct |
10 ms |
2504 KB |
Output is correct |
23 |
Correct |
11 ms |
1736 KB |
Output is correct |
24 |
Correct |
12 ms |
2644 KB |
Output is correct |
25 |
Correct |
12 ms |
3232 KB |
Output is correct |
26 |
Correct |
11 ms |
2700 KB |
Output is correct |
27 |
Correct |
7 ms |
852 KB |
Output is correct |
28 |
Correct |
7 ms |
976 KB |
Output is correct |
29 |
Correct |
6 ms |
852 KB |
Output is correct |
30 |
Correct |
21 ms |
3548 KB |
Output is correct |
31 |
Correct |
25 ms |
4812 KB |
Output is correct |
32 |
Correct |
20 ms |
4856 KB |
Output is correct |
33 |
Correct |
67 ms |
6492 KB |
Output is correct |
34 |
Correct |
67 ms |
6484 KB |
Output is correct |
35 |
Correct |
83 ms |
6348 KB |
Output is correct |
36 |
Correct |
307 ms |
40652 KB |
Output is correct |
37 |
Correct |
333 ms |
40008 KB |
Output is correct |
38 |
Correct |
405 ms |
36024 KB |
Output is correct |
39 |
Incorrect |
2306 ms |
15524 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
324 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 |
316 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
372 KB |
Output is correct |
19 |
Correct |
7 ms |
588 KB |
Output is correct |
20 |
Correct |
6 ms |
596 KB |
Output is correct |
21 |
Correct |
4 ms |
596 KB |
Output is correct |
22 |
Correct |
10 ms |
2504 KB |
Output is correct |
23 |
Correct |
11 ms |
1736 KB |
Output is correct |
24 |
Correct |
12 ms |
2644 KB |
Output is correct |
25 |
Correct |
12 ms |
3232 KB |
Output is correct |
26 |
Correct |
11 ms |
2700 KB |
Output is correct |
27 |
Correct |
204 ms |
16412 KB |
Output is correct |
28 |
Correct |
214 ms |
16188 KB |
Output is correct |
29 |
Correct |
238 ms |
15936 KB |
Output is correct |
30 |
Correct |
214 ms |
16260 KB |
Output is correct |
31 |
Correct |
293 ms |
16564 KB |
Output is correct |
32 |
Correct |
651 ms |
57756 KB |
Output is correct |
33 |
Correct |
318 ms |
20196 KB |
Output is correct |
34 |
Correct |
387 ms |
26924 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
410 ms |
27656 KB |
Output is correct |
37 |
Correct |
1419 ms |
82464 KB |
Output is correct |
38 |
Correct |
1486 ms |
83016 KB |
Output is correct |
39 |
Correct |
1247 ms |
75960 KB |
Output is correct |
40 |
Correct |
526 ms |
27336 KB |
Output is correct |
41 |
Correct |
172 ms |
13864 KB |
Output is correct |
42 |
Correct |
32 ms |
3924 KB |
Output is correct |
43 |
Correct |
1594 ms |
101932 KB |
Output is correct |
44 |
Correct |
1179 ms |
55188 KB |
Output is correct |
45 |
Correct |
1039 ms |
47676 KB |
Output is correct |
46 |
Correct |
742 ms |
97596 KB |
Output is correct |
47 |
Correct |
310 ms |
20208 KB |
Output is correct |
48 |
Correct |
736 ms |
90056 KB |
Output is correct |
49 |
Correct |
734 ms |
94564 KB |
Output is correct |
50 |
Correct |
250 ms |
18672 KB |
Output is correct |
51 |
Correct |
7 ms |
852 KB |
Output is correct |
52 |
Correct |
7 ms |
976 KB |
Output is correct |
53 |
Correct |
6 ms |
852 KB |
Output is correct |
54 |
Correct |
21 ms |
3548 KB |
Output is correct |
55 |
Correct |
25 ms |
4812 KB |
Output is correct |
56 |
Correct |
20 ms |
4856 KB |
Output is correct |
57 |
Correct |
67 ms |
6492 KB |
Output is correct |
58 |
Correct |
67 ms |
6484 KB |
Output is correct |
59 |
Correct |
83 ms |
6348 KB |
Output is correct |
60 |
Correct |
307 ms |
40652 KB |
Output is correct |
61 |
Correct |
333 ms |
40008 KB |
Output is correct |
62 |
Correct |
405 ms |
36024 KB |
Output is correct |
63 |
Incorrect |
2306 ms |
15524 KB |
Output isn't correct |
64 |
Halted |
0 ms |
0 KB |
- |