#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sq(int x) { return (ll)x * x; }
struct C {
int x, y, r;
void read() { cin >> x >> y >> r; }
bool inter(const C &he) const { return sq(x - he.x) + sq(y - he.y) <= sq(r + he.r); }
};
struct T {
int x, y, id;
T(int xx, int yy, int iid) : x(xx), y(yy), id(iid) {}
bool operator<(const T &he) const { return tie(x, y, id) < tie(he.x, he.y, he.id); }
};
const int oo = 1e9 + 7;
int32_t main()
{
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector<int> ans(n, -1), ord(n);
vector<C> c(n);
for(int i = 0; i < n; i++) {
c[i].read();
ord[i] = i;
}
sort(ord.begin(), ord.end(), [&](auto a, auto b) {
return c[a].r == c[b].r ? a < b : c[a].r > c[b].r;
});
for(int rep = 30; rep >= 1; rep--) {
set<T> aa;
for(int i = 0; i < n; i++) {
if(ans[i] == -1) {
aa.emplace(c[i].x >> rep, c[i].y >> rep, i);
}
}
auto zrob = [&](int i) {
for(int k = -2; k <= 2; k++) {
int x = (c[i].x >> rep) - k;
int lo = (c[i].y >> rep) - 2;
int hi = (c[i].y >> rep) + 2;
auto it = aa.lower_bound(T{x, lo, -1});
while(it != aa.end() && tie(it->x, it->y) <= tie(x, hi)) {
if(c[i].inter(c[it->id])) {
ans[it->id] = i;
it = aa.erase(it);
}
else {
it++;
}
}
}
};
int p = 0;
while(p < n && c[ord[p]].r >= (1 << (rep - 1))) {
if(ans[ord[p]] == -1) {
zrob(ord[p]);
}
p++;
}
}
for(int i = 0; i < n; i++) {
cout << ans[i] + 1 << " ";
}
cout << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
432 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
4 ms |
848 KB |
Output is correct |
20 |
Correct |
4 ms |
888 KB |
Output is correct |
21 |
Correct |
4 ms |
852 KB |
Output is correct |
22 |
Correct |
18 ms |
852 KB |
Output is correct |
23 |
Correct |
20 ms |
804 KB |
Output is correct |
24 |
Correct |
18 ms |
868 KB |
Output is correct |
25 |
Correct |
19 ms |
856 KB |
Output is correct |
26 |
Correct |
18 ms |
872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
295 ms |
33828 KB |
Output is correct |
2 |
Correct |
405 ms |
33700 KB |
Output is correct |
3 |
Correct |
364 ms |
33448 KB |
Output is correct |
4 |
Correct |
236 ms |
33852 KB |
Output is correct |
5 |
Correct |
2788 ms |
31412 KB |
Output is correct |
6 |
Execution timed out |
3057 ms |
29536 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
607 ms |
11836 KB |
Output is correct |
3 |
Execution timed out |
3040 ms |
33056 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3034 ms |
32812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
432 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
4 ms |
848 KB |
Output is correct |
20 |
Correct |
4 ms |
888 KB |
Output is correct |
21 |
Correct |
4 ms |
852 KB |
Output is correct |
22 |
Correct |
18 ms |
852 KB |
Output is correct |
23 |
Correct |
20 ms |
804 KB |
Output is correct |
24 |
Correct |
18 ms |
868 KB |
Output is correct |
25 |
Correct |
19 ms |
856 KB |
Output is correct |
26 |
Correct |
18 ms |
872 KB |
Output is correct |
27 |
Correct |
8 ms |
1492 KB |
Output is correct |
28 |
Correct |
10 ms |
1492 KB |
Output is correct |
29 |
Correct |
9 ms |
1404 KB |
Output is correct |
30 |
Correct |
43 ms |
1476 KB |
Output is correct |
31 |
Correct |
41 ms |
1384 KB |
Output is correct |
32 |
Correct |
41 ms |
1404 KB |
Output is correct |
33 |
Correct |
89 ms |
12256 KB |
Output is correct |
34 |
Correct |
83 ms |
12120 KB |
Output is correct |
35 |
Correct |
107 ms |
12100 KB |
Output is correct |
36 |
Correct |
765 ms |
11604 KB |
Output is correct |
37 |
Correct |
730 ms |
11724 KB |
Output is correct |
38 |
Correct |
685 ms |
11740 KB |
Output is correct |
39 |
Correct |
1071 ms |
10208 KB |
Output is correct |
40 |
Correct |
1018 ms |
10080 KB |
Output is correct |
41 |
Correct |
1044 ms |
10188 KB |
Output is correct |
42 |
Correct |
507 ms |
10696 KB |
Output is correct |
43 |
Correct |
775 ms |
11660 KB |
Output is correct |
44 |
Correct |
683 ms |
11672 KB |
Output is correct |
45 |
Correct |
771 ms |
11724 KB |
Output is correct |
46 |
Correct |
769 ms |
11748 KB |
Output is correct |
47 |
Correct |
824 ms |
11660 KB |
Output is correct |
48 |
Correct |
817 ms |
11668 KB |
Output is correct |
49 |
Correct |
752 ms |
11748 KB |
Output is correct |
50 |
Correct |
801 ms |
11668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
432 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
4 ms |
848 KB |
Output is correct |
20 |
Correct |
4 ms |
888 KB |
Output is correct |
21 |
Correct |
4 ms |
852 KB |
Output is correct |
22 |
Correct |
18 ms |
852 KB |
Output is correct |
23 |
Correct |
20 ms |
804 KB |
Output is correct |
24 |
Correct |
18 ms |
868 KB |
Output is correct |
25 |
Correct |
19 ms |
856 KB |
Output is correct |
26 |
Correct |
18 ms |
872 KB |
Output is correct |
27 |
Correct |
295 ms |
33828 KB |
Output is correct |
28 |
Correct |
405 ms |
33700 KB |
Output is correct |
29 |
Correct |
364 ms |
33448 KB |
Output is correct |
30 |
Correct |
236 ms |
33852 KB |
Output is correct |
31 |
Correct |
2788 ms |
31412 KB |
Output is correct |
32 |
Execution timed out |
3057 ms |
29536 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |