이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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){
long long 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);
}
컴파일 시 표준 에러 (stderr) 메시지
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;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |