답안 #123954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123954 2019-07-02T10:06:06 Z RayanLabidi 원 고르기 (APIO18_circle_selection) C++14
0 / 100
3000 ms 558820 KB
#include <bits/stdc++.h>
#define rp(_s,_i,_n) for(int _s=_i;_s<_n;_s++)
#define sz(_itt) (int)_itt.size()
#define mp(__a,__b) make_pair(__a,__b)
#define pb(_p) push_back(_p)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace std;
typedef long long ll;

struct cir{
    int rad,ind,x,y;
};
bool acomp(cir a,cir b){
    //if(a.rad==b.rad)return a.ind<b.ind;
    return a.rad>b.rad;
}
vector<cir> c;//circles
vector<vector<cir> >con;//circles connected to circle con[i]
int n;//numb of circles
vector<bool>del;
vector<int> killer;
double dist(int x,int y){
    return sqrt((c[x].x-c[y].x)*(c[x].x-c[y].x)+(c[x].y-c[y].y)*(c[x].y-c[y].y));
}
void connecting(int u){
    rp(i,0,n){
        if(i==u)continue;
        if(dist(u,i)<=c[i].rad+c[u].rad){
            con[u].push_back(c[i]);
        }
    }
}
int main()
{
    //fastio

    cin>>n;
    c.resize(n),con.resize(n),del.resize(n),killer.resize(n);
    rp(i,0,n){
        cin>>c[i].x>>c[i].y>>c[i].rad;
        c[i].ind=i;
    }
    sort(c.begin(),c.end(),acomp);
    rp(i,0,n){
        connecting(i);
    }
    rp(i,0,n){
        if(del[c[i].ind]==1)continue;
        del[c[i].ind]=1;
        killer[c[i].ind]=c[i].ind;
        for(auto x:con[i]){
            if(del[x.ind]==1)continue;
            killer[x.ind]=c[i].ind;
            del[x.ind]=1;
        }
    }
    rp(i,0,n){
        cout <<killer[i]+1<<" ";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3067 ms 558820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3034 ms 64748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -