답안 #968187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968187 2024-04-23T08:23:35 Z socpite 원 고르기 (APIO18_circle_selection) C++14
100 / 100
1930 ms 49328 KB
#include<bits/stdc++.h>
using namespace std;

const int maxn = 3e5+5;
const int INF = 1e9;

pair<int, int> pt[maxn];
int R[maxn], removed[maxn];

bool cmp(int a, int b){
    return R[a] != R[b] ? R[a] > R[b] : a < b;
}

int n;

bool check(int a, int b){
    return 1LL*(pt[a].first - pt[b].first)*(pt[a].first - pt[b].first) + 1LL*(pt[a].second - pt[b].second)*(pt[a].second - pt[b].second) - 1LL*(R[a] + R[b])*(R[a] + R[b])  <= 0;
}

map<pair<int, int>, vector<int>> mp;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    vector<int> vec(n);
    iota(vec.begin(), vec.end(), 1);
    int mx = 0;
    for(int i = 1; i <= n; i++){
        cin >> pt[i].first >> pt[i].second >> R[i];
        pt[i].first += INF;
        pt[i].second += INF;
        mx = max(mx, R[i]);
    }
    sort(vec.begin(), vec.end(), cmp);
    for(int i = 1; i <= n; i++){
        mp[{pt[i].first/mx, pt[i].second/mx}].push_back(i);
    }
    for(auto i: vec){
        if(removed[i])continue;
        if(R[i] <= mx/2){
            mx/=2;
            mp.clear();
            for(int j = 1; j <= n; j++){
                if(removed[j])continue;
                mp[{pt[j].first/mx, pt[j].second/mx}].push_back(j);
            }
        }
        for(int j = pt[i].first/mx - 2; j <= pt[i].first/mx + 2; j++){
            for(int k = pt[i].second/mx - 2; k <= pt[i].second/mx + 2; k++){
                if(mp.find(make_pair(j, k)) == mp.end())continue;
                for(auto v: mp[{j, k}])if(!removed[v] && check(v, i))removed[v] = i;
            }
        }
    }
    for(int i = 1; i <= n; i++)cout << removed[i] << " ";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 2 ms 4440 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 3 ms 4696 KB Output is correct
22 Correct 12 ms 5224 KB Output is correct
23 Correct 14 ms 5292 KB Output is correct
24 Correct 14 ms 5208 KB Output is correct
25 Correct 12 ms 5280 KB Output is correct
26 Correct 12 ms 5468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 8516 KB Output is correct
2 Correct 122 ms 15072 KB Output is correct
3 Correct 122 ms 16324 KB Output is correct
4 Correct 126 ms 15772 KB Output is correct
5 Correct 208 ms 15444 KB Output is correct
6 Correct 583 ms 28960 KB Output is correct
7 Correct 182 ms 16996 KB Output is correct
8 Correct 258 ms 19100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 342 ms 19228 KB Output is correct
3 Correct 1682 ms 48720 KB Output is correct
4 Correct 1554 ms 49084 KB Output is correct
5 Correct 1462 ms 42804 KB Output is correct
6 Correct 512 ms 23160 KB Output is correct
7 Correct 185 ms 14732 KB Output is correct
8 Correct 32 ms 6748 KB Output is correct
9 Correct 1771 ms 48240 KB Output is correct
10 Correct 1242 ms 41672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1380 ms 40984 KB Output is correct
2 Correct 977 ms 40984 KB Output is correct
3 Correct 444 ms 18036 KB Output is correct
4 Correct 931 ms 41204 KB Output is correct
5 Correct 943 ms 41212 KB Output is correct
6 Correct 171 ms 11624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 2 ms 4440 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 3 ms 4696 KB Output is correct
22 Correct 12 ms 5224 KB Output is correct
23 Correct 14 ms 5292 KB Output is correct
24 Correct 14 ms 5208 KB Output is correct
25 Correct 12 ms 5280 KB Output is correct
26 Correct 12 ms 5468 KB Output is correct
27 Correct 5 ms 4956 KB Output is correct
28 Correct 5 ms 4952 KB Output is correct
29 Correct 5 ms 4952 KB Output is correct
30 Correct 26 ms 5984 KB Output is correct
31 Correct 24 ms 5976 KB Output is correct
32 Correct 24 ms 5976 KB Output is correct
33 Correct 46 ms 9296 KB Output is correct
34 Correct 43 ms 9168 KB Output is correct
35 Correct 44 ms 8800 KB Output is correct
36 Correct 294 ms 19024 KB Output is correct
37 Correct 297 ms 19224 KB Output is correct
38 Correct 335 ms 19264 KB Output is correct
39 Correct 326 ms 16172 KB Output is correct
40 Correct 332 ms 16168 KB Output is correct
41 Correct 311 ms 16072 KB Output is correct
42 Correct 197 ms 18196 KB Output is correct
43 Correct 243 ms 19028 KB Output is correct
44 Correct 223 ms 18968 KB Output is correct
45 Correct 215 ms 18768 KB Output is correct
46 Correct 235 ms 18960 KB Output is correct
47 Correct 220 ms 18948 KB Output is correct
48 Correct 223 ms 18824 KB Output is correct
49 Correct 212 ms 19020 KB Output is correct
50 Correct 211 ms 19024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 2 ms 4440 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 3 ms 4700 KB Output is correct
21 Correct 3 ms 4696 KB Output is correct
22 Correct 12 ms 5224 KB Output is correct
23 Correct 14 ms 5292 KB Output is correct
24 Correct 14 ms 5208 KB Output is correct
25 Correct 12 ms 5280 KB Output is correct
26 Correct 12 ms 5468 KB Output is correct
27 Correct 122 ms 8516 KB Output is correct
28 Correct 122 ms 15072 KB Output is correct
29 Correct 122 ms 16324 KB Output is correct
30 Correct 126 ms 15772 KB Output is correct
31 Correct 208 ms 15444 KB Output is correct
32 Correct 583 ms 28960 KB Output is correct
33 Correct 182 ms 16996 KB Output is correct
34 Correct 258 ms 19100 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 342 ms 19228 KB Output is correct
37 Correct 1682 ms 48720 KB Output is correct
38 Correct 1554 ms 49084 KB Output is correct
39 Correct 1462 ms 42804 KB Output is correct
40 Correct 512 ms 23160 KB Output is correct
41 Correct 185 ms 14732 KB Output is correct
42 Correct 32 ms 6748 KB Output is correct
43 Correct 1771 ms 48240 KB Output is correct
44 Correct 1242 ms 41672 KB Output is correct
45 Correct 1380 ms 40984 KB Output is correct
46 Correct 977 ms 40984 KB Output is correct
47 Correct 444 ms 18036 KB Output is correct
48 Correct 931 ms 41204 KB Output is correct
49 Correct 943 ms 41212 KB Output is correct
50 Correct 171 ms 11624 KB Output is correct
51 Correct 5 ms 4956 KB Output is correct
52 Correct 5 ms 4952 KB Output is correct
53 Correct 5 ms 4952 KB Output is correct
54 Correct 26 ms 5984 KB Output is correct
55 Correct 24 ms 5976 KB Output is correct
56 Correct 24 ms 5976 KB Output is correct
57 Correct 46 ms 9296 KB Output is correct
58 Correct 43 ms 9168 KB Output is correct
59 Correct 44 ms 8800 KB Output is correct
60 Correct 294 ms 19024 KB Output is correct
61 Correct 297 ms 19224 KB Output is correct
62 Correct 335 ms 19264 KB Output is correct
63 Correct 326 ms 16172 KB Output is correct
64 Correct 332 ms 16168 KB Output is correct
65 Correct 311 ms 16072 KB Output is correct
66 Correct 197 ms 18196 KB Output is correct
67 Correct 243 ms 19028 KB Output is correct
68 Correct 223 ms 18968 KB Output is correct
69 Correct 215 ms 18768 KB Output is correct
70 Correct 235 ms 18960 KB Output is correct
71 Correct 220 ms 18948 KB Output is correct
72 Correct 223 ms 18824 KB Output is correct
73 Correct 212 ms 19020 KB Output is correct
74 Correct 211 ms 19024 KB Output is correct
75 Correct 140 ms 17572 KB Output is correct
76 Correct 126 ms 17208 KB Output is correct
77 Correct 126 ms 18520 KB Output is correct
78 Correct 123 ms 18508 KB Output is correct
79 Correct 149 ms 17288 KB Output is correct
80 Correct 126 ms 18264 KB Output is correct
81 Correct 1503 ms 49036 KB Output is correct
82 Correct 1448 ms 48980 KB Output is correct
83 Correct 1549 ms 48820 KB Output is correct
84 Correct 1718 ms 49328 KB Output is correct
85 Correct 1648 ms 48892 KB Output is correct
86 Correct 1559 ms 49108 KB Output is correct
87 Correct 1848 ms 48856 KB Output is correct
88 Correct 1592 ms 39616 KB Output is correct
89 Correct 1464 ms 39548 KB Output is correct
90 Correct 1403 ms 39688 KB Output is correct
91 Correct 1561 ms 39752 KB Output is correct
92 Correct 1452 ms 39768 KB Output is correct
93 Correct 1136 ms 47956 KB Output is correct
94 Correct 1340 ms 48212 KB Output is correct
95 Correct 1075 ms 48140 KB Output is correct
96 Correct 1131 ms 47908 KB Output is correct
97 Correct 1930 ms 47832 KB Output is correct
98 Correct 717 ms 36172 KB Output is correct
99 Correct 1249 ms 48064 KB Output is correct
100 Correct 1153 ms 47828 KB Output is correct
101 Correct 1078 ms 41404 KB Output is correct
102 Correct 1148 ms 47488 KB Output is correct
103 Correct 1653 ms 47528 KB Output is correct
104 Correct 1248 ms 47848 KB Output is correct
105 Correct 996 ms 45652 KB Output is correct
106 Correct 918 ms 46584 KB Output is correct
107 Correct 897 ms 46760 KB Output is correct
108 Correct 892 ms 46772 KB Output is correct
109 Correct 873 ms 46608 KB Output is correct
110 Correct 874 ms 46876 KB Output is correct
111 Correct 884 ms 46608 KB Output is correct
112 Correct 836 ms 46552 KB Output is correct
113 Correct 906 ms 46620 KB Output is correct
114 Correct 920 ms 46740 KB Output is correct
115 Correct 960 ms 46620 KB Output is correct
116 Correct 889 ms 46700 KB Output is correct