Submission #153244

#TimeUsernameProblemLanguageResultExecution timeMemory
153244usernameCircle selection (APIO18_circle_selection)C++14
49 / 100
3082 ms356040 KiB
#include<bits/stdc++.h> using namespace std; #define REP(i,j,k) for(int i=(j);i<(k);++i) #define pb push_back #define F first #define S second #define IOS cin.tie(0),ios_base::sync_with_stdio(false) #define f2(x) (int64_t(x)*(x)) template<class T> void R(T &x) { x = 0; bool negative = false; char c = ' '; while (c < '-') { c = getchar(); } if (c == '-') { negative = true; c = getchar(); } while (c >= '0') { x = x * 10 + (c - '0'); c = getchar(); } if (negative) { x = -x; } } template<class T> void P(T output) { if (output == 0) { putchar('0'); return; } if (output < 0) { putchar('-'); output = -output; } int buf[20], n = 0; while(output) { buf[n] = ((output % 10)); output /= 10; n++; } for (n--; n >= 0; n--) { putchar(buf[n] + '0'); } return; } const int maxn=3e5+3; struct C{int x,y,r,id;}a[maxn]; int n,res[maxn]; bool rmv[maxn]; unordered_map<int64_t,vector<int>>mp; main(){ IOS; R(n); REP(i,0,n)R(a[i].x),R(a[i].y),R(a[i].r),a[i].id=i; sort(a,a+n,[](C&x,C&y){return x.r==y.r?x.id<y.id:x.r>y.r;}); int k=31; REP(i,0,n){ if(rmv[i])continue; if((a[i].r<<1)<(1ll<<k)){ while((a[i].r<<1)<(1ll<<k))--k; mp.clear(); REP(j,i,n)if(!rmv[j])mp[(int64_t(a[j].x>>k)<<31)+(a[j].y>>k)].pb(j); } int xx=a[i].x>>k,yy=a[i].y>>k; REP(x,xx-5,xx)REP(y,yy-5,yy){ auto&tls=mp[(int64_t(x+3)<<31)+(y+3)]; for(auto it=tls.begin();it!=tls.end();++it){ if(!rmv[*it]&&f2(a[i].x-a[*it].x)+f2(a[i].y-a[*it].y)<=f2(a[i].r+a[*it].r)){ res[a[*it].id]=a[i].id; rmv[*it]=1; } } } } REP(i,0,n)P(res[i]+1),putchar(' '); }

Compilation message (stderr)

circle_selection.cpp:68:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#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...