답안 #439264

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439264 2021-06-29T13:03:05 Z RGBB 원 고르기 (APIO18_circle_selection) C++14
100 / 100
959 ms 143104 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pp;
const int MAXN=300000;
const int rnd=1e9+7;
const int base=4405829;
bool vis[MAXN];
int n,cr,outp[MAXN],inp[MAXN][3];
pp take[MAXN];
vector<int>plane[base],reset;
int cmp(int a,int b){
    return abs((a*rnd+b)%base);
}
void create(){
    for(int i:reset)plane[i].clear();
    reset.clear();
    for(pp i:take){
        if(vis[i.second])continue;
        int h=cmp(inp[i.second][0]>>cr,inp[i.second][1]>>cr);
        if(plane[h].size()==0)reset.push_back(h);
        plane[h].push_back(i.second);
    }
}
ll xx,yy,rr;
bool intersect(int a,int b){
    xx=inp[a][0]-inp[b][0];
    yy=inp[a][1]-inp[b][1];
    rr=inp[a][2]+inp[b][2];
    if(xx*xx+yy*yy<=rr*rr)return true;
    return false;
}
void calc(int c){
    int cx=(inp[c][0]>>cr);
    int cy=(inp[c][1]>>cr);
    for(int i=-1;i<=1;i++){
        for(int y=-1;y<=1;y++){
            for(int i:plane[cmp(cx+i,cy+y)]){
                if(!vis[i]&&intersect(i,c)){
                    outp[i]=c;
                    vis[i]=true;
                }
            }
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(vis,false,sizeof(vis));
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>inp[i][0]>>inp[i][1]>>inp[i][2];
        take[i]={-inp[i][2],i};
    }
    sort(take,take+n);
    cr=30;
    create();
    bool change=false;
    for(int i=0;i<n;i++){
        if(vis[take[i].second])continue;
        while(-take[i].first<(double)(1<<(cr-2))/sqrt(2)){
            cr--;
            change=true;
        }
        if(change)create();
        change=false;
        calc(take[i].second);
    }
    for(int i=0;i<n-1;i++)cout<<outp[i]+1<<" ";
    cout<<outp[n-1]+1<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 108220 KB Output is correct
2 Correct 73 ms 108336 KB Output is correct
3 Correct 77 ms 106180 KB Output is correct
4 Correct 80 ms 109504 KB Output is correct
5 Correct 67 ms 106180 KB Output is correct
6 Correct 67 ms 106276 KB Output is correct
7 Correct 68 ms 106176 KB Output is correct
8 Correct 69 ms 106264 KB Output is correct
9 Correct 84 ms 109480 KB Output is correct
10 Correct 72 ms 106172 KB Output is correct
11 Correct 113 ms 115404 KB Output is correct
12 Correct 76 ms 108348 KB Output is correct
13 Correct 82 ms 109532 KB Output is correct
14 Correct 81 ms 109488 KB Output is correct
15 Correct 87 ms 110620 KB Output is correct
16 Correct 67 ms 106272 KB Output is correct
17 Correct 83 ms 108280 KB Output is correct
18 Correct 66 ms 106296 KB Output is correct
19 Correct 70 ms 106316 KB Output is correct
20 Correct 68 ms 106304 KB Output is correct
21 Correct 85 ms 106328 KB Output is correct
22 Correct 92 ms 109868 KB Output is correct
23 Correct 94 ms 109820 KB Output is correct
24 Correct 116 ms 113452 KB Output is correct
25 Correct 101 ms 111176 KB Output is correct
26 Correct 98 ms 109860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 246 ms 114524 KB Output is correct
2 Correct 259 ms 114608 KB Output is correct
3 Correct 246 ms 114624 KB Output is correct
4 Correct 276 ms 114876 KB Output is correct
5 Correct 278 ms 115896 KB Output is correct
6 Correct 476 ms 119628 KB Output is correct
7 Correct 356 ms 116428 KB Output is correct
8 Correct 337 ms 117472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 108328 KB Output is correct
2 Correct 261 ms 115792 KB Output is correct
3 Correct 851 ms 139852 KB Output is correct
4 Correct 870 ms 140056 KB Output is correct
5 Correct 797 ms 132068 KB Output is correct
6 Correct 373 ms 118452 KB Output is correct
7 Correct 191 ms 112168 KB Output is correct
8 Correct 111 ms 111632 KB Output is correct
9 Correct 959 ms 143104 KB Output is correct
10 Correct 744 ms 127396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 486 ms 124424 KB Output is correct
2 Correct 473 ms 124436 KB Output is correct
3 Correct 321 ms 115988 KB Output is correct
4 Correct 477 ms 124480 KB Output is correct
5 Correct 470 ms 124516 KB Output is correct
6 Correct 301 ms 115876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 108220 KB Output is correct
2 Correct 73 ms 108336 KB Output is correct
3 Correct 77 ms 106180 KB Output is correct
4 Correct 80 ms 109504 KB Output is correct
5 Correct 67 ms 106180 KB Output is correct
6 Correct 67 ms 106276 KB Output is correct
7 Correct 68 ms 106176 KB Output is correct
8 Correct 69 ms 106264 KB Output is correct
9 Correct 84 ms 109480 KB Output is correct
10 Correct 72 ms 106172 KB Output is correct
11 Correct 113 ms 115404 KB Output is correct
12 Correct 76 ms 108348 KB Output is correct
13 Correct 82 ms 109532 KB Output is correct
14 Correct 81 ms 109488 KB Output is correct
15 Correct 87 ms 110620 KB Output is correct
16 Correct 67 ms 106272 KB Output is correct
17 Correct 83 ms 108280 KB Output is correct
18 Correct 66 ms 106296 KB Output is correct
19 Correct 70 ms 106316 KB Output is correct
20 Correct 68 ms 106304 KB Output is correct
21 Correct 85 ms 106328 KB Output is correct
22 Correct 92 ms 109868 KB Output is correct
23 Correct 94 ms 109820 KB Output is correct
24 Correct 116 ms 113452 KB Output is correct
25 Correct 101 ms 111176 KB Output is correct
26 Correct 98 ms 109860 KB Output is correct
27 Correct 79 ms 106412 KB Output is correct
28 Correct 75 ms 106432 KB Output is correct
29 Correct 71 ms 106412 KB Output is correct
30 Correct 106 ms 110220 KB Output is correct
31 Correct 105 ms 110252 KB Output is correct
32 Correct 117 ms 111632 KB Output is correct
33 Correct 129 ms 108348 KB Output is correct
34 Correct 127 ms 108288 KB Output is correct
35 Correct 135 ms 108364 KB Output is correct
36 Correct 274 ms 116196 KB Output is correct
37 Correct 292 ms 118832 KB Output is correct
38 Correct 322 ms 117944 KB Output is correct
39 Correct 395 ms 110012 KB Output is correct
40 Correct 441 ms 110084 KB Output is correct
41 Correct 402 ms 109944 KB Output is correct
42 Correct 161 ms 110648 KB Output is correct
43 Correct 205 ms 112108 KB Output is correct
44 Correct 227 ms 112040 KB Output is correct
45 Correct 201 ms 112068 KB Output is correct
46 Correct 207 ms 112000 KB Output is correct
47 Correct 205 ms 112040 KB Output is correct
48 Correct 208 ms 111992 KB Output is correct
49 Correct 201 ms 111996 KB Output is correct
50 Correct 205 ms 111944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 108220 KB Output is correct
2 Correct 73 ms 108336 KB Output is correct
3 Correct 77 ms 106180 KB Output is correct
4 Correct 80 ms 109504 KB Output is correct
5 Correct 67 ms 106180 KB Output is correct
6 Correct 67 ms 106276 KB Output is correct
7 Correct 68 ms 106176 KB Output is correct
8 Correct 69 ms 106264 KB Output is correct
9 Correct 84 ms 109480 KB Output is correct
10 Correct 72 ms 106172 KB Output is correct
11 Correct 113 ms 115404 KB Output is correct
12 Correct 76 ms 108348 KB Output is correct
13 Correct 82 ms 109532 KB Output is correct
14 Correct 81 ms 109488 KB Output is correct
15 Correct 87 ms 110620 KB Output is correct
16 Correct 67 ms 106272 KB Output is correct
17 Correct 83 ms 108280 KB Output is correct
18 Correct 66 ms 106296 KB Output is correct
19 Correct 70 ms 106316 KB Output is correct
20 Correct 68 ms 106304 KB Output is correct
21 Correct 85 ms 106328 KB Output is correct
22 Correct 92 ms 109868 KB Output is correct
23 Correct 94 ms 109820 KB Output is correct
24 Correct 116 ms 113452 KB Output is correct
25 Correct 101 ms 111176 KB Output is correct
26 Correct 98 ms 109860 KB Output is correct
27 Correct 246 ms 114524 KB Output is correct
28 Correct 259 ms 114608 KB Output is correct
29 Correct 246 ms 114624 KB Output is correct
30 Correct 276 ms 114876 KB Output is correct
31 Correct 278 ms 115896 KB Output is correct
32 Correct 476 ms 119628 KB Output is correct
33 Correct 356 ms 116428 KB Output is correct
34 Correct 337 ms 117472 KB Output is correct
35 Correct 83 ms 108328 KB Output is correct
36 Correct 261 ms 115792 KB Output is correct
37 Correct 851 ms 139852 KB Output is correct
38 Correct 870 ms 140056 KB Output is correct
39 Correct 797 ms 132068 KB Output is correct
40 Correct 373 ms 118452 KB Output is correct
41 Correct 191 ms 112168 KB Output is correct
42 Correct 111 ms 111632 KB Output is correct
43 Correct 959 ms 143104 KB Output is correct
44 Correct 744 ms 127396 KB Output is correct
45 Correct 486 ms 124424 KB Output is correct
46 Correct 473 ms 124436 KB Output is correct
47 Correct 321 ms 115988 KB Output is correct
48 Correct 477 ms 124480 KB Output is correct
49 Correct 470 ms 124516 KB Output is correct
50 Correct 301 ms 115876 KB Output is correct
51 Correct 79 ms 106412 KB Output is correct
52 Correct 75 ms 106432 KB Output is correct
53 Correct 71 ms 106412 KB Output is correct
54 Correct 106 ms 110220 KB Output is correct
55 Correct 105 ms 110252 KB Output is correct
56 Correct 117 ms 111632 KB Output is correct
57 Correct 129 ms 108348 KB Output is correct
58 Correct 127 ms 108288 KB Output is correct
59 Correct 135 ms 108364 KB Output is correct
60 Correct 274 ms 116196 KB Output is correct
61 Correct 292 ms 118832 KB Output is correct
62 Correct 322 ms 117944 KB Output is correct
63 Correct 395 ms 110012 KB Output is correct
64 Correct 441 ms 110084 KB Output is correct
65 Correct 402 ms 109944 KB Output is correct
66 Correct 161 ms 110648 KB Output is correct
67 Correct 205 ms 112108 KB Output is correct
68 Correct 227 ms 112040 KB Output is correct
69 Correct 201 ms 112068 KB Output is correct
70 Correct 207 ms 112000 KB Output is correct
71 Correct 205 ms 112040 KB Output is correct
72 Correct 208 ms 111992 KB Output is correct
73 Correct 201 ms 111996 KB Output is correct
74 Correct 205 ms 111944 KB Output is correct
75 Correct 272 ms 114128 KB Output is correct
76 Correct 272 ms 115676 KB Output is correct
77 Correct 289 ms 115652 KB Output is correct
78 Correct 244 ms 114108 KB Output is correct
79 Correct 362 ms 116140 KB Output is correct
80 Correct 243 ms 114180 KB Output is correct
81 Correct 763 ms 135612 KB Output is correct
82 Correct 834 ms 137172 KB Output is correct
83 Correct 871 ms 140568 KB Output is correct
84 Correct 828 ms 139356 KB Output is correct
85 Correct 952 ms 138864 KB Output is correct
86 Correct 912 ms 137404 KB Output is correct
87 Correct 824 ms 138732 KB Output is correct
88 Correct 660 ms 116560 KB Output is correct
89 Correct 621 ms 116668 KB Output is correct
90 Correct 711 ms 116592 KB Output is correct
91 Correct 712 ms 116632 KB Output is correct
92 Correct 658 ms 116640 KB Output is correct
93 Correct 629 ms 132080 KB Output is correct
94 Correct 736 ms 136252 KB Output is correct
95 Correct 642 ms 132884 KB Output is correct
96 Correct 714 ms 135228 KB Output is correct
97 Correct 686 ms 136812 KB Output is correct
98 Correct 551 ms 120668 KB Output is correct
99 Correct 946 ms 139080 KB Output is correct
100 Correct 590 ms 130988 KB Output is correct
101 Correct 661 ms 123820 KB Output is correct
102 Correct 813 ms 136184 KB Output is correct
103 Correct 714 ms 133528 KB Output is correct
104 Correct 771 ms 136844 KB Output is correct
105 Correct 408 ms 116024 KB Output is correct
106 Correct 509 ms 121728 KB Output is correct
107 Correct 483 ms 121672 KB Output is correct
108 Correct 483 ms 121648 KB Output is correct
109 Correct 539 ms 121628 KB Output is correct
110 Correct 519 ms 121680 KB Output is correct
111 Correct 486 ms 121680 KB Output is correct
112 Correct 484 ms 121668 KB Output is correct
113 Correct 510 ms 121788 KB Output is correct
114 Correct 504 ms 121700 KB Output is correct
115 Correct 487 ms 121512 KB Output is correct
116 Correct 485 ms 121876 KB Output is correct