Submission #971555

#TimeUsernameProblemLanguageResultExecution timeMemory
971555irmuunCircle selection (APIO18_circle_selection)C++17
0 / 100
3051 ms1048576 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() const ll N=3e5+5; ll n; ll x[N],y[N],r[N]; vector<ll>adj[N],ans(N); vector<bool>used(N,0); ll dist(ll i,ll j){ return abs(x[i]-x[j])*abs(x[i]-x[j])+abs(y[i]-y[j])*abs(y[i]-y[j]); } void dfs(ll x,ll s){ ans[x]=s; used[x]=true; for(ll y:adj[x]){ if(!used[y]){ dfs(y,s); } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; set<pair<ll,ll>>st; for(ll i=1;i<=n;i++){ cin>>x[i]>>y[i]>>r[i]; st.insert({-r[i],i}); } for(ll i=1;i<=n;i++){ for(ll j=i+1;j<=n;j++){ if(dist(i,j)<=(r[i]+r[j])*(r[i]+r[j])){ adj[i].pb(j); adj[j].pb(i); } } } while(!st.empty()){ ll i=st.begin()->ss; st.erase(st.begin()); if(!used[i]) dfs(i,i); } for(ll i=1;i<=n;i++){ cout<<ans[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...