#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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 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 |
212 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 |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
468 KB |
Output is correct |
20 |
Correct |
4 ms |
468 KB |
Output is correct |
21 |
Correct |
6 ms |
468 KB |
Output is correct |
22 |
Correct |
14 ms |
2388 KB |
Output is correct |
23 |
Correct |
9 ms |
1640 KB |
Output is correct |
24 |
Correct |
11 ms |
2516 KB |
Output is correct |
25 |
Correct |
12 ms |
3100 KB |
Output is correct |
26 |
Correct |
10 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
9508 KB |
Output is correct |
2 |
Correct |
229 ms |
9568 KB |
Output is correct |
3 |
Correct |
207 ms |
9344 KB |
Output is correct |
4 |
Correct |
200 ms |
9540 KB |
Output is correct |
5 |
Correct |
254 ms |
11976 KB |
Output is correct |
6 |
Correct |
607 ms |
53220 KB |
Output is correct |
7 |
Correct |
305 ms |
15744 KB |
Output is correct |
8 |
Correct |
381 ms |
22492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
365 ms |
25100 KB |
Output is correct |
3 |
Correct |
1354 ms |
74760 KB |
Output is correct |
4 |
Correct |
1272 ms |
75104 KB |
Output is correct |
5 |
Correct |
1139 ms |
68280 KB |
Output is correct |
6 |
Correct |
405 ms |
23208 KB |
Output is correct |
7 |
Correct |
183 ms |
11868 KB |
Output is correct |
8 |
Correct |
23 ms |
3788 KB |
Output is correct |
9 |
Correct |
1294 ms |
94028 KB |
Output is correct |
10 |
Correct |
1057 ms |
47028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
892 ms |
40104 KB |
Output is correct |
2 |
Correct |
644 ms |
90872 KB |
Output is correct |
3 |
Correct |
307 ms |
12028 KB |
Output is correct |
4 |
Correct |
653 ms |
82924 KB |
Output is correct |
5 |
Correct |
598 ms |
87200 KB |
Output is correct |
6 |
Correct |
230 ms |
10316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 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 |
212 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 |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
468 KB |
Output is correct |
20 |
Correct |
4 ms |
468 KB |
Output is correct |
21 |
Correct |
6 ms |
468 KB |
Output is correct |
22 |
Correct |
14 ms |
2388 KB |
Output is correct |
23 |
Correct |
9 ms |
1640 KB |
Output is correct |
24 |
Correct |
11 ms |
2516 KB |
Output is correct |
25 |
Correct |
12 ms |
3100 KB |
Output is correct |
26 |
Correct |
10 ms |
2644 KB |
Output is correct |
27 |
Correct |
10 ms |
900 KB |
Output is correct |
28 |
Correct |
8 ms |
844 KB |
Output is correct |
29 |
Correct |
6 ms |
844 KB |
Output is correct |
30 |
Correct |
25 ms |
3640 KB |
Output is correct |
31 |
Correct |
20 ms |
4876 KB |
Output is correct |
32 |
Correct |
26 ms |
4948 KB |
Output is correct |
33 |
Correct |
62 ms |
3580 KB |
Output is correct |
34 |
Correct |
72 ms |
3692 KB |
Output is correct |
35 |
Correct |
68 ms |
3740 KB |
Output is correct |
36 |
Correct |
315 ms |
38328 KB |
Output is correct |
37 |
Correct |
275 ms |
37616 KB |
Output is correct |
38 |
Correct |
367 ms |
33664 KB |
Output is correct |
39 |
Incorrect |
2214 ms |
14768 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 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 |
212 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 |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
468 KB |
Output is correct |
20 |
Correct |
4 ms |
468 KB |
Output is correct |
21 |
Correct |
6 ms |
468 KB |
Output is correct |
22 |
Correct |
14 ms |
2388 KB |
Output is correct |
23 |
Correct |
9 ms |
1640 KB |
Output is correct |
24 |
Correct |
11 ms |
2516 KB |
Output is correct |
25 |
Correct |
12 ms |
3100 KB |
Output is correct |
26 |
Correct |
10 ms |
2644 KB |
Output is correct |
27 |
Correct |
199 ms |
9508 KB |
Output is correct |
28 |
Correct |
229 ms |
9568 KB |
Output is correct |
29 |
Correct |
207 ms |
9344 KB |
Output is correct |
30 |
Correct |
200 ms |
9540 KB |
Output is correct |
31 |
Correct |
254 ms |
11976 KB |
Output is correct |
32 |
Correct |
607 ms |
53220 KB |
Output is correct |
33 |
Correct |
305 ms |
15744 KB |
Output is correct |
34 |
Correct |
381 ms |
22492 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
365 ms |
25100 KB |
Output is correct |
37 |
Correct |
1354 ms |
74760 KB |
Output is correct |
38 |
Correct |
1272 ms |
75104 KB |
Output is correct |
39 |
Correct |
1139 ms |
68280 KB |
Output is correct |
40 |
Correct |
405 ms |
23208 KB |
Output is correct |
41 |
Correct |
183 ms |
11868 KB |
Output is correct |
42 |
Correct |
23 ms |
3788 KB |
Output is correct |
43 |
Correct |
1294 ms |
94028 KB |
Output is correct |
44 |
Correct |
1057 ms |
47028 KB |
Output is correct |
45 |
Correct |
892 ms |
40104 KB |
Output is correct |
46 |
Correct |
644 ms |
90872 KB |
Output is correct |
47 |
Correct |
307 ms |
12028 KB |
Output is correct |
48 |
Correct |
653 ms |
82924 KB |
Output is correct |
49 |
Correct |
598 ms |
87200 KB |
Output is correct |
50 |
Correct |
230 ms |
10316 KB |
Output is correct |
51 |
Correct |
10 ms |
900 KB |
Output is correct |
52 |
Correct |
8 ms |
844 KB |
Output is correct |
53 |
Correct |
6 ms |
844 KB |
Output is correct |
54 |
Correct |
25 ms |
3640 KB |
Output is correct |
55 |
Correct |
20 ms |
4876 KB |
Output is correct |
56 |
Correct |
26 ms |
4948 KB |
Output is correct |
57 |
Correct |
62 ms |
3580 KB |
Output is correct |
58 |
Correct |
72 ms |
3692 KB |
Output is correct |
59 |
Correct |
68 ms |
3740 KB |
Output is correct |
60 |
Correct |
315 ms |
38328 KB |
Output is correct |
61 |
Correct |
275 ms |
37616 KB |
Output is correct |
62 |
Correct |
367 ms |
33664 KB |
Output is correct |
63 |
Incorrect |
2214 ms |
14768 KB |
Output isn't correct |
64 |
Halted |
0 ms |
0 KB |
- |