답안 #552808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552808 2022-04-24T03:50:24 Z zaneyu 원 고르기 (APIO18_circle_selection) C++14
100 / 100
2147 ms 59024 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;

#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=3e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
int MOD=2;
const int INF=0x3f3f3f3f;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<P.f<<' '<<P.s;
    return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
    REP(i,sz(V)) out<<V[i]<<((i!=sz(V)-1)?" ":"");
    return out;
}
int mult(ll a,ll b){
    if(a<0) a+=MOD;
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}

int n;
pair<pii,ll> arr[maxn];
int x[maxn],y[maxn],ans[maxn];
int blk=1e9;
map<pii,vector<int>> mp;
bool del[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);
}
void rebuild(){
    mp.clear();
    REP(i,n){
        if(del[i]) continue;
        x[i]=arr[i].f.f/blk;
        y[i]=arr[i].f.s/blk;
        mp[{x[i],y[i]}].pb(i);
    }
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    cin>>n;
    set<int> s;
    vector<pii> vv;
    REP(i,n) cin>>arr[i].f.f>>arr[i].f.s>>arr[i].s,vv.pb({arr[i].s,-i});
    sort(ALL(vv));
    reverse(ALL(vv));
    rebuild();
    REP(asd,n){
        int i=-vv[asd].s;
        if(del[i]) continue;
        if(blk>2*arr[i].s){
            blk=arr[i].s;
            rebuild();
        }
        for(int j=x[i]-2;j<=x[i]+2;j++){
            for(int k=y[i]-2;k<=y[i]+2;k++){
                if(!mp.count({j,k})) continue;
                vector<int> nw;
                for(int x:mp[{j,k}]){
                    if(inter(x,i)){
                        del[x]=1;
                        ans[x]=i;
                    }
                    else nw.pb(x);
                }
                mp[{j,k}]=nw;
            }
        }
    }
    REP(i,n){
        cout<<ans[i]+1<<' ';
    }
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 3 ms 864 KB Output is correct
20 Correct 3 ms 852 KB Output is correct
21 Correct 3 ms 856 KB Output is correct
22 Correct 14 ms 1296 KB Output is correct
23 Correct 15 ms 1236 KB Output is correct
24 Correct 14 ms 1308 KB Output is correct
25 Correct 12 ms 1240 KB Output is correct
26 Correct 13 ms 1244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 150 ms 27964 KB Output is correct
2 Correct 151 ms 27828 KB Output is correct
3 Correct 145 ms 27496 KB Output is correct
4 Correct 151 ms 27852 KB Output is correct
5 Correct 201 ms 25572 KB Output is correct
6 Correct 710 ms 38828 KB Output is correct
7 Correct 264 ms 26924 KB Output is correct
8 Correct 322 ms 28888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 457 ms 19776 KB Output is correct
3 Correct 1869 ms 58840 KB Output is correct
4 Correct 1828 ms 58836 KB Output is correct
5 Correct 1842 ms 52160 KB Output is correct
6 Correct 589 ms 26280 KB Output is correct
7 Correct 239 ms 14272 KB Output is correct
8 Correct 30 ms 3224 KB Output is correct
9 Correct 2147 ms 57904 KB Output is correct
10 Correct 1586 ms 51300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1477 ms 58716 KB Output is correct
2 Correct 1038 ms 57812 KB Output is correct
3 Correct 425 ms 35972 KB Output is correct
4 Correct 1117 ms 58184 KB Output is correct
5 Correct 1104 ms 58480 KB Output is correct
6 Correct 235 ms 29896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 3 ms 864 KB Output is correct
20 Correct 3 ms 852 KB Output is correct
21 Correct 3 ms 856 KB Output is correct
22 Correct 14 ms 1296 KB Output is correct
23 Correct 15 ms 1236 KB Output is correct
24 Correct 14 ms 1308 KB Output is correct
25 Correct 12 ms 1240 KB Output is correct
26 Correct 13 ms 1244 KB Output is correct
27 Correct 6 ms 1380 KB Output is correct
28 Correct 8 ms 1484 KB Output is correct
29 Correct 6 ms 1236 KB Output is correct
30 Correct 37 ms 2228 KB Output is correct
31 Correct 26 ms 2236 KB Output is correct
32 Correct 26 ms 2248 KB Output is correct
33 Correct 52 ms 10056 KB Output is correct
34 Correct 54 ms 10048 KB Output is correct
35 Correct 53 ms 9888 KB Output is correct
36 Correct 414 ms 19536 KB Output is correct
37 Correct 417 ms 19648 KB Output is correct
38 Correct 402 ms 19740 KB Output is correct
39 Correct 346 ms 16604 KB Output is correct
40 Correct 356 ms 16536 KB Output is correct
41 Correct 320 ms 16560 KB Output is correct
42 Correct 310 ms 18648 KB Output is correct
43 Correct 265 ms 19420 KB Output is correct
44 Correct 273 ms 19408 KB Output is correct
45 Correct 277 ms 19452 KB Output is correct
46 Correct 277 ms 19324 KB Output is correct
47 Correct 259 ms 19444 KB Output is correct
48 Correct 296 ms 19368 KB Output is correct
49 Correct 296 ms 19388 KB Output is correct
50 Correct 262 ms 19392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 3 ms 864 KB Output is correct
20 Correct 3 ms 852 KB Output is correct
21 Correct 3 ms 856 KB Output is correct
22 Correct 14 ms 1296 KB Output is correct
23 Correct 15 ms 1236 KB Output is correct
24 Correct 14 ms 1308 KB Output is correct
25 Correct 12 ms 1240 KB Output is correct
26 Correct 13 ms 1244 KB Output is correct
27 Correct 150 ms 27964 KB Output is correct
28 Correct 151 ms 27828 KB Output is correct
29 Correct 145 ms 27496 KB Output is correct
30 Correct 151 ms 27852 KB Output is correct
31 Correct 201 ms 25572 KB Output is correct
32 Correct 710 ms 38828 KB Output is correct
33 Correct 264 ms 26924 KB Output is correct
34 Correct 322 ms 28888 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 457 ms 19776 KB Output is correct
37 Correct 1869 ms 58840 KB Output is correct
38 Correct 1828 ms 58836 KB Output is correct
39 Correct 1842 ms 52160 KB Output is correct
40 Correct 589 ms 26280 KB Output is correct
41 Correct 239 ms 14272 KB Output is correct
42 Correct 30 ms 3224 KB Output is correct
43 Correct 2147 ms 57904 KB Output is correct
44 Correct 1586 ms 51300 KB Output is correct
45 Correct 1477 ms 58716 KB Output is correct
46 Correct 1038 ms 57812 KB Output is correct
47 Correct 425 ms 35972 KB Output is correct
48 Correct 1117 ms 58184 KB Output is correct
49 Correct 1104 ms 58480 KB Output is correct
50 Correct 235 ms 29896 KB Output is correct
51 Correct 6 ms 1380 KB Output is correct
52 Correct 8 ms 1484 KB Output is correct
53 Correct 6 ms 1236 KB Output is correct
54 Correct 37 ms 2228 KB Output is correct
55 Correct 26 ms 2236 KB Output is correct
56 Correct 26 ms 2248 KB Output is correct
57 Correct 52 ms 10056 KB Output is correct
58 Correct 54 ms 10048 KB Output is correct
59 Correct 53 ms 9888 KB Output is correct
60 Correct 414 ms 19536 KB Output is correct
61 Correct 417 ms 19648 KB Output is correct
62 Correct 402 ms 19740 KB Output is correct
63 Correct 346 ms 16604 KB Output is correct
64 Correct 356 ms 16536 KB Output is correct
65 Correct 320 ms 16560 KB Output is correct
66 Correct 310 ms 18648 KB Output is correct
67 Correct 265 ms 19420 KB Output is correct
68 Correct 273 ms 19408 KB Output is correct
69 Correct 277 ms 19452 KB Output is correct
70 Correct 277 ms 19324 KB Output is correct
71 Correct 259 ms 19444 KB Output is correct
72 Correct 296 ms 19368 KB Output is correct
73 Correct 296 ms 19388 KB Output is correct
74 Correct 262 ms 19392 KB Output is correct
75 Correct 197 ms 30208 KB Output is correct
76 Correct 172 ms 29900 KB Output is correct
77 Correct 161 ms 30124 KB Output is correct
78 Correct 152 ms 30048 KB Output is correct
79 Correct 198 ms 29824 KB Output is correct
80 Correct 150 ms 29856 KB Output is correct
81 Correct 1776 ms 58764 KB Output is correct
82 Correct 1719 ms 58572 KB Output is correct
83 Correct 1706 ms 58540 KB Output is correct
84 Correct 1936 ms 59024 KB Output is correct
85 Correct 1786 ms 58648 KB Output is correct
86 Correct 1682 ms 58796 KB Output is correct
87 Correct 2121 ms 58548 KB Output is correct
88 Correct 1285 ms 49176 KB Output is correct
89 Correct 1317 ms 49152 KB Output is correct
90 Correct 1246 ms 49272 KB Output is correct
91 Correct 1250 ms 49272 KB Output is correct
92 Correct 1216 ms 49180 KB Output is correct
93 Correct 1224 ms 57588 KB Output is correct
94 Correct 1376 ms 57844 KB Output is correct
95 Correct 1224 ms 57744 KB Output is correct
96 Correct 1265 ms 57596 KB Output is correct
97 Correct 2009 ms 57604 KB Output is correct
98 Correct 864 ms 45820 KB Output is correct
99 Correct 1292 ms 57808 KB Output is correct
100 Correct 1088 ms 57860 KB Output is correct
101 Correct 1214 ms 50972 KB Output is correct
102 Correct 1270 ms 57160 KB Output is correct
103 Correct 1908 ms 57204 KB Output is correct
104 Correct 1250 ms 57504 KB Output is correct
105 Correct 1103 ms 55304 KB Output is correct
106 Correct 957 ms 56332 KB Output is correct
107 Correct 962 ms 56316 KB Output is correct
108 Correct 990 ms 56296 KB Output is correct
109 Correct 965 ms 56328 KB Output is correct
110 Correct 959 ms 56368 KB Output is correct
111 Correct 969 ms 56248 KB Output is correct
112 Correct 1053 ms 56296 KB Output is correct
113 Correct 956 ms 56376 KB Output is correct
114 Correct 969 ms 56292 KB Output is correct
115 Correct 990 ms 56364 KB Output is correct
116 Correct 935 ms 56252 KB Output is correct