Submission #106551

#TimeUsernameProblemLanguageResultExecution timeMemory
106551usernameCircle selection (APIO18_circle_selection)C++14
49 / 100
3115 ms284632 KiB
#include<bits/stdc++.h> #define int int64_t using namespace std; typedef pair<int,int> pii; #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) ((x)*(x)) const int maxn=3e5+3,inf=1ll<<60,bl=2e9+3; struct C{int x,y,r,id;}a[maxn]; int n,res[maxn]; bitset<maxn>rmv; unordered_map<int,vector<int>>mp; main(){ IOS; cin>>n; REP(i,0,n)cin>>a[i].x>>a[i].y>>a[i].r,a[i].id=i; stable_sort(a,a+n,[](const C&x,const C&y){return x.r>y.r;}); int k=inf; REP(i,0,n){ if(rmv[i])continue; if(2*a[i].r<k){ k=a[i].r; mp.clear(); REP(j,i,n)if(!rmv[j])mp[a[j].x/k*bl+a[j].y/k].pb(j); } int xx=a[i].x/k,yy=a[i].y/k; REP(x,xx-2,xx+3)REP(y,yy-2,yy+3){ auto&tls=mp[x*bl+y]; 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)cout<<res[i]+1<<" "; }

Compilation message (stderr)

circle_selection.cpp:18: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...