Submission #971555

# Submission time Handle Problem Language Result Execution time Memory
971555 2024-04-29T00:26:04 Z irmuun Circle selection (APIO18_circle_selection) C++17
0 / 100
3000 ms 1048576 KB
#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 time Memory Grader output
1 Correct 4 ms 15192 KB Output is correct
2 Correct 3 ms 15340 KB Output is correct
3 Correct 4 ms 15196 KB Output is correct
4 Correct 3 ms 15336 KB Output is correct
5 Correct 4 ms 15196 KB Output is correct
6 Correct 4 ms 15452 KB Output is correct
7 Correct 3 ms 15448 KB Output is correct
8 Incorrect 4 ms 15196 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2383 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 15352 KB Output is correct
2 Execution timed out 3050 ms 21628 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3051 ms 35496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 15192 KB Output is correct
2 Correct 3 ms 15340 KB Output is correct
3 Correct 4 ms 15196 KB Output is correct
4 Correct 3 ms 15336 KB Output is correct
5 Correct 4 ms 15196 KB Output is correct
6 Correct 4 ms 15452 KB Output is correct
7 Correct 3 ms 15448 KB Output is correct
8 Incorrect 4 ms 15196 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 15192 KB Output is correct
2 Correct 3 ms 15340 KB Output is correct
3 Correct 4 ms 15196 KB Output is correct
4 Correct 3 ms 15336 KB Output is correct
5 Correct 4 ms 15196 KB Output is correct
6 Correct 4 ms 15452 KB Output is correct
7 Correct 3 ms 15448 KB Output is correct
8 Incorrect 4 ms 15196 KB Output isn't correct
9 Halted 0 ms 0 KB -