#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define forn(i, n) for(int i=0; i<n; ++i)
#define F first
#define S second
#define PB push_back
struct circle{
pii c;
int r, ind;
};
struct quad{
pii a[4];
quad(pii A, pii B, pii C, pii D){a[0]=A, a[1]=B, a[2]=C, a[3]=D;}
};
pii reduce(pii a, int ind){
return {(a.F>>ind), (a.S>>ind)};
}
quad cover(pii c, int r, int i){
pii lelo={c.F-r, c.S-r}, lehi={c.F-r, c.S+r}, rilo={c.F+r, c.S-r}, rihi={c.F+r, c.S+r};
return quad(reduce(lelo, i), reduce(lehi, i), reduce(rilo, i), reduce(rihi, i));
}
bool inters(circle a, circle b){
ll dx=b.c.F-a.c.F, dy=b.c.S-a.c.S, sum=a.r+b.r;
return (dx*dx + dy*dy <= sum*sum);
}
const int MAXN=300010;
int n, ans[MAXN];
circle arr[MAXN];
map<pii, vector<int>> mp[36];
int main(){
scanf("%d", &n);
forn(i, n){
scanf("%d %d %d", &arr[i].c.F, &arr[i].c.S, &arr[i].r);
arr[i].ind=i;
}
sort(arr, arr+n, [](circle a, circle b){
return a.r!=b.r? a.r>b.r : a.ind<b.ind;
});
forn(i, n){
int mn=i;
forn(j, 31) if((1<<j)>arr[i].r){
quad cov = cover(arr[i].c, arr[i].r, j);
forn(k, 4) for(int ind:mp[j][cov.a[k]]) if(inters(arr[i], arr[ind])) mn=min(mn, ind), cout << i << ' ' << ind << ' ' << mn << endl;
}
ans[arr[i].ind]=arr[mn].ind;
if(mn==i){
int ex = 8*sizeof(int)-__builtin_clz(arr[i].r);
quad q = cover(arr[i].c, arr[i].r, ex);
forn(j, 4) mp[ex][q.a[j]].PB(i);
}
}
forn(i, n) printf("%d ", ans[i]+1);
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
circle_selection.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
45 | scanf("%d %d %d", &arr[i].c.F, &arr[i].c.S, &arr[i].r);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Incorrect |
2 ms |
4948 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1973 ms |
30016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3018 ms |
241496 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Incorrect |
2 ms |
4948 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Incorrect |
2 ms |
4948 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |