답안 #1073858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073858 2024-08-25T00:20:46 Z ngrace 원 고르기 (APIO18_circle_selection) C++14
7 / 100
823 ms 62364 KB
#include <bits/stdc++.h>
using namespace std;
#define v vector
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second

struct Circle{
    ll x, y, r, i;
};

int N;
v<Circle> C;

bool compC(Circle& a, Circle& b){
    if(a.r==b.r) return a.i<b.i;
    return a.r>b.r;
}
bool isect(Circle& a, Circle& b){
    ll dx=a.x-b.x;
    ll dy=a.y-b.y;
    ll r=a.r+b.r;
    return dx*dx+dy*dy <= r*r;
}

v<ll> eBy;

void sub1(){
    for(int i=0; i<N; i++){
        if(eBy[C[i].i]!=-1) continue;
        eBy[C[i].i] = C[i].i;
        for(int j=i+1; j<N; j++){
            if(eBy[C[j].i]==-1 && isect(C[i], C[j])){
                eBy[C[j].i] = C[i].i;
            }
        }
    }
}

void sub2(){
    set<ii> pts;
    for(int i=0; i<N; i++){
        pts.insert(make_pair(C[i].x-C[i].r, i));
        pts.insert(make_pair(C[i].x+C[i].r, i));
    }

    for(int i=0; i<N; i++){
        v<int> del;
        auto it = pts.lower_bound(make_pair(C[i].x-C[i].r, -1));
        while(it!=pts.end() && (*it).fi<=C[i].x+C[i].r){
            int ind = (*it).se;
            eBy[C[ind].i] = C[i].i;
            del.push_back(ind);
            it++;
        }
        for(int ind:del){
            pts.erase(make_pair(C[ind].x-C[ind].r, ind));
            pts.erase(make_pair(C[ind].x+C[ind].r, ind));
        }
    }
}

void sub3(){

}

void sub4(){

}

void full(){

}

int main(){
    cin>>N;
    bool s2 = true;
    bool s4 = true;
    for(int i=0; i<N; i++){
        ll x,y,r;
        cin>>x>>y>>r;
        C.push_back({x,y,r,i});
        s2 = s2 && y==0;
        s4 = s4 && r==C[0].r;
    }
    sort(C.begin(), C.end(), compC);

    eBy = v<ll>(N,-1);

    if(N<=5000) sub1();
    else if(s2) sub2();
    else if(s4) sub4();
    else sub3();

    for(int i:eBy) cout<<i+1<<" ";
    cout<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 6 ms 860 KB Output is correct
20 Correct 5 ms 860 KB Output is correct
21 Correct 5 ms 860 KB Output is correct
22 Correct 24 ms 960 KB Output is correct
23 Correct 24 ms 860 KB Output is correct
24 Correct 24 ms 856 KB Output is correct
25 Correct 24 ms 864 KB Output is correct
26 Correct 29 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 823 ms 62364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 85 ms 8416 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 250 ms 23988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 6 ms 860 KB Output is correct
20 Correct 5 ms 860 KB Output is correct
21 Correct 5 ms 860 KB Output is correct
22 Correct 24 ms 960 KB Output is correct
23 Correct 24 ms 860 KB Output is correct
24 Correct 24 ms 856 KB Output is correct
25 Correct 24 ms 864 KB Output is correct
26 Correct 29 ms 856 KB Output is correct
27 Incorrect 9 ms 1240 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 6 ms 860 KB Output is correct
20 Correct 5 ms 860 KB Output is correct
21 Correct 5 ms 860 KB Output is correct
22 Correct 24 ms 960 KB Output is correct
23 Correct 24 ms 860 KB Output is correct
24 Correct 24 ms 856 KB Output is correct
25 Correct 24 ms 864 KB Output is correct
26 Correct 29 ms 856 KB Output is correct
27 Incorrect 823 ms 62364 KB Output isn't correct
28 Halted 0 ms 0 KB -