제출 #737184

#제출 시각아이디문제언어결과실행 시간메모리
737184Username4132원 고르기 (APIO18_circle_selection)C++14
7 / 100
3052 ms15052 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...