Submission #771713

# Submission time Handle Problem Language Result Execution time Memory
771713 2023-07-03T08:20:24 Z gagik_2007 Circle selection (APIO18_circle_selection) C++17
7 / 100
328 ms 17612 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

class Circle {
public:
    ll x,y;
    ll r;
    int ind;
    Circle(ll xx, ll yy, ll rr, int i){
        x=xx;
        y=yy;
        r=rr;
        ind=i;
    }
    bool operator<(const Circle& other) const{
        if(r==other.r)return ind>other.ind;
        return r<other.r;
    }
};

ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=3e5+7;
ll n,m,k;
vector<Circle>d;
bool jnj[N];

bool isHatel(const Circle& a, const Circle& b){
    ll xt=a.x-b.x;
    ll yt=a.y-b.y;
    ll rt=a.r+b.r;
    return xt*xt+yt*yt<=rt*rt;
}

bool comp(const Circle& a, const Circle& b){
    return a.x<b.x;
}

int main() {
    cin>>n;
    for(int i=0;i<n;i++){
        int x,y,r;
        cin>>x>>y>>r;
        d.push_back(Circle(x,y,r,i));
    }
    vector<int>ans(n);
    if(n<=5000){
        sort(d.begin(),d.end());
        reverse(d.begin(),d.end());
        for(int i=0;i<n;i++){
            // cout<<d[i].ind<<" ";
            if(!jnj[d[i].ind]){
                ans[d[i].ind]=d[i].ind;
                jnj[d[i].ind]=true;
                for(int j=0;j<n;j++){
                    if(!jnj[d[j].ind]&&isHatel(d[i],d[j])){
                        ans[d[j].ind]=d[i].ind;
                        jnj[d[j].ind]=true;
                    }
                }
            }
        }
        for(int x:ans)cout<<1+x<<" ";
        cout<<endl;
        return 0;
    }
    sort(d.begin(),d.end(),comp);
    vector<int>p;
    vector<int>rp(n);
    for(int i=0;i<n;i++){
        p.push_back(d[i].ind);
        rp[d[i].ind]=i;
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    for(int i=0;i<n;i++){
        if(!jnj[d[i].ind]){
            ans[d[i].ind]=d[i].ind;
            jnj[d[i].ind]=true;
            int ind=rp[d[i].ind];
            int l=ind-1;
            while(l>=0&&isHatel(d[p[l]],d[i])){
                ans[d[p[l]].ind]=d[i].ind;
                jnj[d[p[l]].ind]=true;
                l--;
            }
            int r=ind+1;
            while(r<n&&isHatel(d[p[r]],d[i])){
                ans[d[p[r]].ind]=d[i].ind;
                jnj[d[p[r]].ind]=true;
                r++;
            }
        }
    }
    for(int x:ans)cout<<1+x<<" ";
    cout<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 5 ms 596 KB Output is correct
20 Correct 5 ms 596 KB Output is correct
21 Correct 6 ms 592 KB Output is correct
22 Correct 34 ms 604 KB Output is correct
23 Correct 30 ms 596 KB Output is correct
24 Correct 31 ms 616 KB Output is correct
25 Correct 31 ms 596 KB Output is correct
26 Correct 32 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 296 ms 17612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 109 ms 5736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 328 ms 17452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 5 ms 596 KB Output is correct
20 Correct 5 ms 596 KB Output is correct
21 Correct 6 ms 592 KB Output is correct
22 Correct 34 ms 604 KB Output is correct
23 Correct 30 ms 596 KB Output is correct
24 Correct 31 ms 616 KB Output is correct
25 Correct 31 ms 596 KB Output is correct
26 Correct 32 ms 596 KB Output is correct
27 Incorrect 11 ms 848 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 5 ms 596 KB Output is correct
20 Correct 5 ms 596 KB Output is correct
21 Correct 6 ms 592 KB Output is correct
22 Correct 34 ms 604 KB Output is correct
23 Correct 30 ms 596 KB Output is correct
24 Correct 31 ms 616 KB Output is correct
25 Correct 31 ms 596 KB Output is correct
26 Correct 32 ms 596 KB Output is correct
27 Incorrect 296 ms 17612 KB Output isn't correct
28 Halted 0 ms 0 KB -