#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using pii=pair<int, int>;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
struct circle{
int x, y, r, ind;
circle(int X=0, int Y=0, int R=0) : x(X), y(Y), r(R){}
};
bool operator< (circle a, circle b){
return a.r!=b.r? a.r>b.r : a.ind<b.ind;
}
const int MAXN=300010, LOG=32, dif[3]={-1, 0, 1};
int n, ans[MAXN];
circle arr[MAXN];
vector<circle> cirList;
bool inters(circle a, circle b){
int dx=a.x-b.x, dy=a.y-b.y, sr=a.r+b.r;
return dx*dx <= sr*sr - dy*dy;
}
void insert(circle c){
cirList.push_back(c);
}
int check(circle c){
circle ret; ret.ind=-1;
for(circle cr:cirList) if(inters(c, cr)) ret=min(ret, cr);
return ret.ind;
}
int main(){
scanf("%d", &n);
forn(i, n) scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r), arr[i].ind=i;
sort(arr, arr+n);
forn(i, n){
int val = check(arr[i]);
if(val==-1){
ans[arr[i].ind]=arr[i].ind;
insert(arr[i]);
}
else ans[arr[i].ind]=val;
}
forn(i, n) printf("%d ", ans[i]+1);
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
circle_selection.cpp:40:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | forn(i, n) scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r), arr[i].ind=i;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
172 ms |
8212 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 |
Incorrect |
155 ms |
6784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |