답안 #252639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252639 2020-07-26T02:31:45 Z khangal 원 고르기 (APIO18_circle_selection) C++14
0 / 100
3000 ms 249172 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long , long long > pl;
const int N=1e6+1;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18 
#define MIN -1e18
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,ans,mid,mn,mx,cnt,T,sum,h1,h2,e[1234567],b[1234567],c[1234567],d[1<<20],k,i,j,l,h,a[1234567],w,x,y,z;
ll c1[123][123];
bool used[1234567],used1[1234567];
pl p[1234567];
string s,s1[1234567];
map<ll,ll> mp;
map<pl,ll> mpl;
vector<pl> vec,vec1,ansvec;
vector<ll> v[1234567],v1[1234567];
vector<ll> vp[1234567];
set<ll> st;
stack <ll> sta;
set<pl>sp;
struct node{
    ll x,y,r,id;
}str[1234567];
vector<node> conn[1234567];
bool comp(node a,node b){
    if(a.r==b.r)return a.id<b.id;
    return a.r>b.r;
}
ll dist(ll x,ll y){
    return (str[x].x-str[y].x)*(str[x].x-str[y].x)+(str[x].y-str[y].y)*(str[x].y-str[y].y);
}
void connect(ll x){
    rep(i,1,n){
        if(i==x)continue;
        ll tmp=(str[i].r+str[x].r)*(str[i].r+str[x].r);
        if(dist(x , i) <= tmp){
            conn[x].pb(str[i]);
        }
    }
}
void solve(ll ii ,int r){
    for(ll i=mp[p[ii].ff-p[ii].ss];i<=mp[p[ii].ff+p[ii].ss];i++){
        for(auto it : v[i]){
            if(d[it])continue;
            sp.erase({p[it].ss,-it});
            d[it]=r;
 
        }
        for(auto it:v1[i]){
            if(d[it])continue;
            sp.erase({p[it].ss,-it});
            d[it]=r;
        }
    }
}
int main(){
    cin>>n;
    if(n<=5000){
    rep(i,1,n){
        cin>>str[i].x>>str[i].y>>str[i].r;
        str[i].id=i;
    }
    sort(str+1,str+n+1,comp);
    rep(i,1,n){
        connect(i);
    }
    rep(i,1,n){
        if(used[str[i].id]==1)continue;
        used[str[i].id]=1;
        d[str[i].id] = str[i].id;
        for(auto x : conn[i]){
            if(used[x.id]==1)continue;
            d[x.id] = str[i].id;
            used[x.id]=1;
        }
    }
    rep(i,1,n){
        cout<<d[i]<<" ";
    }}
    ll xx[1234567],yy[1234567],zz[1234567];
    ll res=0;
    rep(i,1,n){
        cin>>xx[i]>>yy[i]>>zz[i];
        res+=(yy[i]!=yy[1]);
    }
    if(res==0){
    rep(i,1,n){
        p[i] = {xx[i],zz[i]};
        mp[xx[i]+zz[i]]++;mp[xx[i]-zz[i]]++;
    }
    ll cnt=0;
    for(auto it : mp){
        mp[it.ff]=++cnt;
    }
    rep(i,1,n){
        x = mp[p[i].ff-p[i].ss];
        y = mp[p[i].ff+p[i].ss];
        v[x].pb(i);
        v1[y].pb(i);
    }
    rep(i,1,n)
        sp.insert({p[i].ss,-i});
    while(!sp.empty()){
        pl pa = *sp.rbegin();
        pa.ss = -pa.ss;
        solve(pa.ss,pa.ss+1);
    }
    rep(i,1,n)cout<<d[i]<<" ";}
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3079 ms 155000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2235 ms 249172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3082 ms 155000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 593 ms 164824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3079 ms 155000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3079 ms 155000 KB Time limit exceeded
2 Halted 0 ms 0 KB -