답안 #552437

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552437 2022-04-23T07:19:22 Z zaneyu 원 고르기 (APIO18_circle_selection) C++14
12 / 100
1723 ms 93688 KB
/*input
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
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);
}
bool ok[maxn];
int ans[maxn];
int seg[4*maxn];
int lazy[4*maxn];
void pushdown(int idx,int l,int r){
    if(!lazy[idx]) return;
    seg[idx]=lazy[idx];
    if(l==r){
        lazy[idx]=0;
        return;
    }
    lazy[idx*2]=lazy[idx*2+1]=lazy[idx];   
    lazy[idx]=0;
}
void upd(int idx,int l,int r,int ql,int qr,int x){
    pushdown(idx,l,r);
    if(r<ql or l>qr) return;
    if(ql<=l and r<=qr){
        lazy[idx]=x;
        pushdown(idx,l,r);
        return;
    }
    int mid=(l+r)/2;
    upd(idx*2,l,mid,ql,qr,x),upd(idx*2+1,mid+1,r,ql,qr,x);
    seg[idx]=max(seg[idx*2],seg[idx*2+1]);
}
int query(int idx,int l,int r,int ql,int qr){
    if(r<ql or l>qr) return 0;
    pushdown(idx,l,r);
    if(ql<=l and r<=qr) return seg[idx];
    int mid=(l+r)/2;
    return max(query(idx*2,l,mid,ql,qr),query(idx*2+1,mid+1,r,ql,qr));
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    map<int,int> mp;
    set<int> s;
    vector<pii> vv;
    REP(i,n) cin>>arr[i].f.f>>arr[i].f.s>>arr[i].s,s.insert(arr[i].f.f-arr[i].s),s.insert(arr[i].f.f+arr[i].s),vv.pb({arr[i].s,-i});
    vector<int> v(ALL(s));
    REP(i,sz(v)) mp[v[i]]=i;
    sort(ALL(vv));
    reverse(ALL(vv));
    REP(asd,n){
        int i=-vv[asd].s;
        int l=mp[arr[i].f.f-arr[i].s],r=mp[arr[i].f.f+arr[i].s];
        int k=query(1,0,sz(v)-1,l,r);
        if(k) ans[i]=n-k;
        else upd(1,0,sz(v)-1,l,r,n-asd),ans[i]=asd;
    }
    REP(i,n){
        cout<<-vv[ans[i]].s+1<<' ';
    }
}

Compilation message

circle_selection.cpp:17: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
   17 | #pragma target("avx3")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1636 ms 88388 KB Output is correct
2 Correct 1723 ms 90100 KB Output is correct
3 Correct 1661 ms 89720 KB Output is correct
4 Correct 1675 ms 88516 KB Output is correct
5 Correct 1086 ms 51792 KB Output is correct
6 Correct 1178 ms 93688 KB Output is correct
7 Correct 1365 ms 88332 KB Output is correct
8 Correct 1349 ms 91016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1428 ms 90548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -