답안 #971559

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971559 2024-04-29T00:57:28 Z irmuun 원 고르기 (APIO18_circle_selection) C++17
19 / 100
790 ms 269900 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,0);
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]);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    vector<pair<ll,ll>>v;
    bool Y=true;
    for(ll i=1;i<=n;i++){
        cin>>x[i]>>y[i]>>r[i];
        v.pb({-r[i],i});
        Y&=(y[i]==0);
    }
    sort(all(v));
    if(n<=5000){
        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);
                }
            }
        }
        for(auto [R,i]:v){
            if(ans[i]>0) continue;
            ans[i]=i;
            for(ll j:adj[i]){
                if(ans[j]==0) ans[j]=i;
            }
        }
        for(ll i=1;i<=n;i++){
            cout<<ans[i]<<' ';
        }
        return 0;
    }
    if(Y){
        set<pair<ll,ll>>L,R;
        for(ll i=1;i<=n;i++){
            L.insert({x[i]-r[i],i});
            R.insert({x[i]+r[i],i});
        }
        vector<ll>del;
        for(auto [ra,i]:v){
            if(ans[i]>0) continue;
            del.clear();
            auto it=L.lower_bound({x[i]-r[i],0});
            while(it!=L.end()&&it->ff<=x[i]+r[i]){
                del.pb(it->ss);
                it++;
            }
            auto it1=R.lower_bound({x[i]-r[i],0});
            while(it1!=R.end()&&it1->ff<=x[i]+r[i]){
                del.pb(it1->ss);
                it1++;
            }
            for(auto j:del){
                if(ans[j]==0){
                    ans[j]=i;
                    L.erase({x[j]-r[j],j});
                    R.erase({x[j]+r[j],j});
                }
            }
        }
        for(ll i=1;i<=n;i++){
            cout<<ans[i]<<' ';
        }
        cout<<"\n";
        return 0;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15196 KB Output is correct
2 Correct 3 ms 15196 KB Output is correct
3 Correct 5 ms 15196 KB Output is correct
4 Correct 4 ms 15188 KB Output is correct
5 Correct 4 ms 15196 KB Output is correct
6 Correct 4 ms 15452 KB Output is correct
7 Correct 4 ms 15452 KB Output is correct
8 Correct 3 ms 15196 KB Output is correct
9 Correct 3 ms 15196 KB Output is correct
10 Correct 4 ms 15196 KB Output is correct
11 Correct 4 ms 15196 KB Output is correct
12 Correct 4 ms 15196 KB Output is correct
13 Correct 3 ms 15192 KB Output is correct
14 Correct 4 ms 15196 KB Output is correct
15 Correct 4 ms 15196 KB Output is correct
16 Correct 10 ms 23644 KB Output is correct
17 Correct 10 ms 23132 KB Output is correct
18 Correct 11 ms 23900 KB Output is correct
19 Correct 259 ms 269500 KB Output is correct
20 Correct 242 ms 269900 KB Output is correct
21 Correct 192 ms 171980 KB Output is correct
22 Correct 19 ms 15452 KB Output is correct
23 Correct 20 ms 15552 KB Output is correct
24 Correct 18 ms 15556 KB Output is correct
25 Correct 22 ms 15448 KB Output is correct
26 Correct 23 ms 15452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 738 ms 70576 KB Output is correct
2 Correct 771 ms 65516 KB Output is correct
3 Correct 728 ms 68252 KB Output is correct
4 Correct 790 ms 70332 KB Output is correct
5 Correct 581 ms 62868 KB Output is correct
6 Correct 596 ms 62712 KB Output is correct
7 Correct 537 ms 62396 KB Output is correct
8 Correct 546 ms 61592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15192 KB Output is correct
2 Incorrect 34 ms 17368 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 26240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15196 KB Output is correct
2 Correct 3 ms 15196 KB Output is correct
3 Correct 5 ms 15196 KB Output is correct
4 Correct 4 ms 15188 KB Output is correct
5 Correct 4 ms 15196 KB Output is correct
6 Correct 4 ms 15452 KB Output is correct
7 Correct 4 ms 15452 KB Output is correct
8 Correct 3 ms 15196 KB Output is correct
9 Correct 3 ms 15196 KB Output is correct
10 Correct 4 ms 15196 KB Output is correct
11 Correct 4 ms 15196 KB Output is correct
12 Correct 4 ms 15196 KB Output is correct
13 Correct 3 ms 15192 KB Output is correct
14 Correct 4 ms 15196 KB Output is correct
15 Correct 4 ms 15196 KB Output is correct
16 Correct 10 ms 23644 KB Output is correct
17 Correct 10 ms 23132 KB Output is correct
18 Correct 11 ms 23900 KB Output is correct
19 Correct 259 ms 269500 KB Output is correct
20 Correct 242 ms 269900 KB Output is correct
21 Correct 192 ms 171980 KB Output is correct
22 Correct 19 ms 15452 KB Output is correct
23 Correct 20 ms 15552 KB Output is correct
24 Correct 18 ms 15556 KB Output is correct
25 Correct 22 ms 15448 KB Output is correct
26 Correct 23 ms 15452 KB Output is correct
27 Incorrect 6 ms 15708 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15196 KB Output is correct
2 Correct 3 ms 15196 KB Output is correct
3 Correct 5 ms 15196 KB Output is correct
4 Correct 4 ms 15188 KB Output is correct
5 Correct 4 ms 15196 KB Output is correct
6 Correct 4 ms 15452 KB Output is correct
7 Correct 4 ms 15452 KB Output is correct
8 Correct 3 ms 15196 KB Output is correct
9 Correct 3 ms 15196 KB Output is correct
10 Correct 4 ms 15196 KB Output is correct
11 Correct 4 ms 15196 KB Output is correct
12 Correct 4 ms 15196 KB Output is correct
13 Correct 3 ms 15192 KB Output is correct
14 Correct 4 ms 15196 KB Output is correct
15 Correct 4 ms 15196 KB Output is correct
16 Correct 10 ms 23644 KB Output is correct
17 Correct 10 ms 23132 KB Output is correct
18 Correct 11 ms 23900 KB Output is correct
19 Correct 259 ms 269500 KB Output is correct
20 Correct 242 ms 269900 KB Output is correct
21 Correct 192 ms 171980 KB Output is correct
22 Correct 19 ms 15452 KB Output is correct
23 Correct 20 ms 15552 KB Output is correct
24 Correct 18 ms 15556 KB Output is correct
25 Correct 22 ms 15448 KB Output is correct
26 Correct 23 ms 15452 KB Output is correct
27 Correct 738 ms 70576 KB Output is correct
28 Correct 771 ms 65516 KB Output is correct
29 Correct 728 ms 68252 KB Output is correct
30 Correct 790 ms 70332 KB Output is correct
31 Correct 581 ms 62868 KB Output is correct
32 Correct 596 ms 62712 KB Output is correct
33 Correct 537 ms 62396 KB Output is correct
34 Correct 546 ms 61592 KB Output is correct
35 Correct 3 ms 15192 KB Output is correct
36 Incorrect 34 ms 17368 KB Output isn't correct
37 Halted 0 ms 0 KB -