Submission #552504

# Submission time Handle Problem Language Result Execution time Memory
552504 2022-04-23T09:03:27 Z zaneyu Circle selection (APIO18_circle_selection) C++14
15 / 100
628 ms 60092 KB
/*input
4
9 9 2
11 8 2
12 14 1
14 14 1
*/
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma target("avx3")
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
const int maxn=6e5+5;
#define pb push_back
#define lowb(x) x&(-x)
#define ll long long
#define MNTO(x,y) x=min(x,y)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define pii pair<ll,ll>
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define sz(x) (int)x.size()
pair<pii,ll> arr[maxn];
inline bool inter(int a,int b){
    ll d=(arr[a].f.s-arr[b].f.s)*(arr[a].f.s-arr[b].f.s)+(arr[a].f.f-arr[b].f.f)*(arr[a].f.f-arr[b].f.f);
    return d<=(arr[a].s+arr[b].s)*(arr[a].s+arr[b].s);
}
int ans[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    map<int,int> mp;
    set<pii> s;
    vector<pii> vv;
    REP1(i,n) cin>>arr[i].f.f>>arr[i].f.s>>arr[i].s,vv.pb({arr[i].f.f-arr[i].s,-i}),vv.pb({arr[i].f.f+arr[i].s,i});
    sort(ALL(vv));
    vector<pii> prs;
    for(auto x:vv){
        int i=abs(x.s);
        if(x.s>0){
            auto it=s.find({arr[i].f.s,i});
            if(it!=s.begin() and it!=prev(s.end())){
                if(inter((*prev(it)).s,(*next(it)).s)) prs.pb({(*prev(it)).s,(*next(it)).s});
            }
            s.erase(it);
        }
        else{
            s.insert({arr[i].f.s,i});
            auto it=s.find({arr[i].f.s,i});
            if(it!=s.begin()){
                if(inter((*prev(it)).s,i)) prs.pb({(*prev(it)).s,i});
            }
            if(it!=prev(s.end())){
                if(inter(i,(*next(it)).s)) prs.pb({i,(*next(it)).s});
            }
        }
       //for(auto x:s) cout<<x.f<<' '<<x.s<<'\n';
       // cout<<'\n';
    }
    REP1(i,n) ans[i]=i;
    for(auto x:prs){
        pii a={arr[x.f].s,-x.f},b={arr[x.s].s,-x.s};
        if(a>b) ans[x.f]=ans[x.s]=x.f;
        else ans[x.f]=ans[x.s]=x.s;
    }
    REP1(i,n) cout<<ans[i]<<' ';
}

Compilation message

circle_selection.cpp:10: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
   10 | #pragma target("avx3")
      |
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 628 ms 60092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 82 ms 9624 KB Output is correct
3 Correct 258 ms 30256 KB Output is correct
4 Correct 257 ms 30252 KB Output is correct
5 Correct 270 ms 30668 KB Output is correct
6 Correct 137 ms 18096 KB Output is correct
7 Correct 69 ms 9532 KB Output is correct
8 Correct 12 ms 2264 KB Output is correct
9 Correct 255 ms 30248 KB Output is correct
10 Correct 292 ms 34768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 254 ms 28700 KB Output is correct
2 Correct 194 ms 29396 KB Output is correct
3 Incorrect 350 ms 49796 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Halted 0 ms 0 KB -