답안 #250927

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250927 2020-07-19T13:06:46 Z nvmdava 원 고르기 (APIO18_circle_selection) C++17
100 / 100
2405 ms 42544 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define N 300005
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;

int x[N], y[N], r[N];
int lr = 2'000'000'002;
int ans[N];
int n;

vector<pair<int, int> > v;

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

inline ll pw(ll a){
    return a * a;
}

bool check(int i, int j){
    return pw(x[i] - x[j]) + pw(y[i] - y[j]) <= pw(r[i] + r[j]);
}

inline int divv(int a, int b){
    return a / b - (a < 0 && a % b != 0);
}

void reset(int r){
    id.clear();
    for(int i = 1; i <= n; ++i){
        if(ans[i]) continue;
        int xx = divv(x[i], r);
        int yy = divv(y[i], r);
        id[{xx, yy}].push_back(i);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i = 1; i <= n; ++i){
        cin>>x[i]>>y[i]>>r[i];
        v.push_back({-r[i], i});
    }


    sort(v.begin(), v.end());

    for(auto& w : v){
        if(ans[w.ss]) continue;
        if(lr >= 2 * r[w.ss])
            reset(lr = r[w.ss]);
        int xx = divv(x[w.ss], lr);
        int yy = divv(y[w.ss], lr);
        for(int dx = -2; dx <= 2; ++dx){
            for(int dy = -2; dy <= 2; ++dy){
                auto it = id.find({xx + dx, yy + dy});
                if(it == id.end()) continue;
                for(int i = 0; i < it -> ss.size(); ++i){
                    if(check(it -> ss[i], w.ss)){
                        ans[it -> ss[i]] = w.ss;
                        swap(it -> ss[i], it -> ss.back());
                        it -> ss.pop_back();
                        --i;
                    }
                }
                if(it -> ss.empty())
                    id.erase(it);

            }
        }
    }

    for(int i = 1; i <= n; ++i)
        cout<<ans[i]<<' ';
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:66:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int i = 0; i < it -> ss.size(); ++i){
                                ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 3 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 13 ms 1152 KB Output is correct
23 Correct 16 ms 1024 KB Output is correct
24 Correct 13 ms 1024 KB Output is correct
25 Correct 11 ms 1024 KB Output is correct
26 Correct 13 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 179 ms 11620 KB Output is correct
2 Correct 183 ms 11616 KB Output is correct
3 Correct 174 ms 11104 KB Output is correct
4 Correct 172 ms 11360 KB Output is correct
5 Correct 229 ms 12000 KB Output is correct
6 Correct 661 ms 25568 KB Output is correct
7 Correct 284 ms 13468 KB Output is correct
8 Correct 381 ms 15696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 455 ms 14320 KB Output is correct
3 Correct 1868 ms 42232 KB Output is correct
4 Correct 1808 ms 42208 KB Output is correct
5 Correct 1715 ms 35932 KB Output is correct
6 Correct 560 ms 17644 KB Output is correct
7 Correct 215 ms 9712 KB Output is correct
8 Correct 31 ms 2424 KB Output is correct
9 Correct 2076 ms 41404 KB Output is correct
10 Correct 1542 ms 34528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1253 ms 42360 KB Output is correct
2 Correct 944 ms 42336 KB Output is correct
3 Correct 384 ms 19148 KB Output is correct
4 Correct 973 ms 42544 KB Output is correct
5 Correct 971 ms 42252 KB Output is correct
6 Correct 272 ms 12768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 3 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 13 ms 1152 KB Output is correct
23 Correct 16 ms 1024 KB Output is correct
24 Correct 13 ms 1024 KB Output is correct
25 Correct 11 ms 1024 KB Output is correct
26 Correct 13 ms 1024 KB Output is correct
27 Correct 7 ms 768 KB Output is correct
28 Correct 7 ms 768 KB Output is correct
29 Correct 7 ms 768 KB Output is correct
30 Correct 30 ms 1784 KB Output is correct
31 Correct 27 ms 1784 KB Output is correct
32 Correct 26 ms 1792 KB Output is correct
33 Correct 67 ms 4104 KB Output is correct
34 Correct 78 ms 3600 KB Output is correct
35 Correct 73 ms 3956 KB Output is correct
36 Correct 399 ms 14316 KB Output is correct
37 Correct 442 ms 14324 KB Output is correct
38 Correct 439 ms 14316 KB Output is correct
39 Correct 265 ms 12748 KB Output is correct
40 Correct 265 ms 12652 KB Output is correct
41 Correct 269 ms 12776 KB Output is correct
42 Correct 183 ms 14320 KB Output is correct
43 Correct 236 ms 14064 KB Output is correct
44 Correct 245 ms 14064 KB Output is correct
45 Correct 237 ms 14060 KB Output is correct
46 Correct 242 ms 14060 KB Output is correct
47 Correct 236 ms 14064 KB Output is correct
48 Correct 234 ms 14068 KB Output is correct
49 Correct 241 ms 14076 KB Output is correct
50 Correct 242 ms 14064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 3 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 13 ms 1152 KB Output is correct
23 Correct 16 ms 1024 KB Output is correct
24 Correct 13 ms 1024 KB Output is correct
25 Correct 11 ms 1024 KB Output is correct
26 Correct 13 ms 1024 KB Output is correct
27 Correct 179 ms 11620 KB Output is correct
28 Correct 183 ms 11616 KB Output is correct
29 Correct 174 ms 11104 KB Output is correct
30 Correct 172 ms 11360 KB Output is correct
31 Correct 229 ms 12000 KB Output is correct
32 Correct 661 ms 25568 KB Output is correct
33 Correct 284 ms 13468 KB Output is correct
34 Correct 381 ms 15696 KB Output is correct
35 Correct 0 ms 384 KB Output is correct
36 Correct 455 ms 14320 KB Output is correct
37 Correct 1868 ms 42232 KB Output is correct
38 Correct 1808 ms 42208 KB Output is correct
39 Correct 1715 ms 35932 KB Output is correct
40 Correct 560 ms 17644 KB Output is correct
41 Correct 215 ms 9712 KB Output is correct
42 Correct 31 ms 2424 KB Output is correct
43 Correct 2076 ms 41404 KB Output is correct
44 Correct 1542 ms 34528 KB Output is correct
45 Correct 1253 ms 42360 KB Output is correct
46 Correct 944 ms 42336 KB Output is correct
47 Correct 384 ms 19148 KB Output is correct
48 Correct 973 ms 42544 KB Output is correct
49 Correct 971 ms 42252 KB Output is correct
50 Correct 272 ms 12768 KB Output is correct
51 Correct 7 ms 768 KB Output is correct
52 Correct 7 ms 768 KB Output is correct
53 Correct 7 ms 768 KB Output is correct
54 Correct 30 ms 1784 KB Output is correct
55 Correct 27 ms 1784 KB Output is correct
56 Correct 26 ms 1792 KB Output is correct
57 Correct 67 ms 4104 KB Output is correct
58 Correct 78 ms 3600 KB Output is correct
59 Correct 73 ms 3956 KB Output is correct
60 Correct 399 ms 14316 KB Output is correct
61 Correct 442 ms 14324 KB Output is correct
62 Correct 439 ms 14316 KB Output is correct
63 Correct 265 ms 12748 KB Output is correct
64 Correct 265 ms 12652 KB Output is correct
65 Correct 269 ms 12776 KB Output is correct
66 Correct 183 ms 14320 KB Output is correct
67 Correct 236 ms 14064 KB Output is correct
68 Correct 245 ms 14064 KB Output is correct
69 Correct 237 ms 14060 KB Output is correct
70 Correct 242 ms 14060 KB Output is correct
71 Correct 236 ms 14064 KB Output is correct
72 Correct 234 ms 14068 KB Output is correct
73 Correct 241 ms 14076 KB Output is correct
74 Correct 242 ms 14064 KB Output is correct
75 Correct 216 ms 11164 KB Output is correct
76 Correct 199 ms 11872 KB Output is correct
77 Correct 197 ms 11876 KB Output is correct
78 Correct 209 ms 11396 KB Output is correct
79 Correct 232 ms 11488 KB Output is correct
80 Correct 193 ms 10680 KB Output is correct
81 Correct 1762 ms 42244 KB Output is correct
82 Correct 1666 ms 42336 KB Output is correct
83 Correct 1651 ms 42352 KB Output is correct
84 Correct 1916 ms 42248 KB Output is correct
85 Correct 1757 ms 42276 KB Output is correct
86 Correct 1750 ms 42336 KB Output is correct
87 Correct 2085 ms 42208 KB Output is correct
88 Correct 1051 ms 37340 KB Output is correct
89 Correct 1045 ms 37344 KB Output is correct
90 Correct 1076 ms 37460 KB Output is correct
91 Correct 1120 ms 37600 KB Output is correct
92 Correct 1050 ms 37360 KB Output is correct
93 Correct 1250 ms 42268 KB Output is correct
94 Correct 1463 ms 41956 KB Output is correct
95 Correct 1258 ms 42304 KB Output is correct
96 Correct 1269 ms 42224 KB Output is correct
97 Correct 2405 ms 42256 KB Output is correct
98 Correct 786 ms 30304 KB Output is correct
99 Correct 1260 ms 42208 KB Output is correct
100 Correct 1203 ms 42464 KB Output is correct
101 Correct 1069 ms 35300 KB Output is correct
102 Correct 1312 ms 41844 KB Output is correct
103 Correct 1880 ms 41824 KB Output is correct
104 Correct 1274 ms 42284 KB Output is correct
105 Correct 764 ms 42080 KB Output is correct
106 Correct 878 ms 40148 KB Output is correct
107 Correct 898 ms 40236 KB Output is correct
108 Correct 895 ms 40168 KB Output is correct
109 Correct 943 ms 40280 KB Output is correct
110 Correct 1002 ms 40088 KB Output is correct
111 Correct 906 ms 40080 KB Output is correct
112 Correct 906 ms 40160 KB Output is correct
113 Correct 899 ms 40292 KB Output is correct
114 Correct 883 ms 40288 KB Output is correct
115 Correct 938 ms 40164 KB Output is correct
116 Correct 878 ms 40056 KB Output is correct