답안 #450360

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
450360 2021-08-02T15:41:05 Z ymm 원 고르기 (APIO18_circle_selection) C++17
100 / 100
2107 ms 54920 KB
///
///    I have a dream and a piano
///

#pragma GCC optimize("O3,unroll-loops")

#define _USE_MATH_DEFINES
#define FAST ios::sync_with_stdio(false),cin.tie(0);
#include <bits/stdc++.h>
#define Loop(x, l, r) for(int x = (l); x < (r); ++x)
#define LoopR(x, l, r) for(int x = (r)-1; x >= (l); --x)
#define all(x) x.begin(), x.end()
#define Kill(x) exit((cout << (x) << '\n', 0))
#define YN(flag) ((flag)? "YES": "NO")
#define F first
#define S second
typedef          long long   ll;
typedef unsigned long long  ull;
typedef std::pair<int,int>  pii;
typedef std::pair<ll ,ll >  pll;
using namespace std;

const int N = 300'010;
ll r[N], x[N], y[N];

inline ll sqr(ll x){return x*x;}
inline bool g(int i, int j){return sqr(x[i]-x[j]) + sqr(y[i]-y[j]) <= sqr(r[i]+r[j]);}

map<pii, vector<pii>> mp[32];
int ans[N];
pll circ[N];
int n;

int main()
{
    FAST;
    cin >> n;
    Loop(i,0,n)
    {
        cin >> x[i] >> y[i] >> r[i];
        x[i] += 1e9; y[i] += 1e9;
        circ[i] = {~r[i], i};
    }
    sort(circ, circ+n);
    Loop(_,0,n)
    {
        int i = circ[_].S;
        int lg = r[i]==1?0:32-__builtin_clz(r[i]-1);
        int mn = 1e9;
        for(int k = lg; k < 32; ++k)
        {
            ll r = k? 1<<(k-1): 0;
            ll d = r? 2*r: 1;
            // (r, d]
            Loop(xx,-1,2) Loop(yy,-1,2){
                auto tmp = mp[k].find(pii{x[i]/(2*d)+xx, y[i]/(2*d)+yy});
                if(tmp == mp[k].end()) continue;
                for(auto [j1, j2] : tmp->S){
                    if(g(i,j2)){
                        mn = min(j1, mn);
                        break;
                    }
                }
            }
        }
        if(mn == 1e9){
            ll r = lg? 1<<(lg-1): 0;
            ll d = r? 2*r: 1;
            mp[lg][pll{x[i]/(2*d), y[i]/(2*d)}].emplace_back(_, i);
            ans[i] = i;
        } else ans[i] = circ[mn].S;
    }
    Loop(i,0,n) cout << ans[i]+1 << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 276 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 392 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 4 ms 716 KB Output is correct
20 Correct 4 ms 720 KB Output is correct
21 Correct 4 ms 716 KB Output is correct
22 Correct 13 ms 1240 KB Output is correct
23 Correct 16 ms 1228 KB Output is correct
24 Correct 13 ms 1192 KB Output is correct
25 Correct 12 ms 1240 KB Output is correct
26 Correct 14 ms 1184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 240 ms 16124 KB Output is correct
2 Correct 245 ms 16072 KB Output is correct
3 Correct 256 ms 16032 KB Output is correct
4 Correct 237 ms 16020 KB Output is correct
5 Correct 803 ms 16348 KB Output is correct
6 Correct 1280 ms 25852 KB Output is correct
7 Correct 916 ms 16880 KB Output is correct
8 Correct 935 ms 18500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 484 ms 16736 KB Output is correct
3 Correct 1747 ms 48520 KB Output is correct
4 Correct 1839 ms 48468 KB Output is correct
5 Correct 1849 ms 38568 KB Output is correct
6 Correct 689 ms 17056 KB Output is correct
7 Correct 313 ms 9284 KB Output is correct
8 Correct 39 ms 2496 KB Output is correct
9 Correct 2107 ms 46816 KB Output is correct
10 Correct 1773 ms 32048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 999 ms 48588 KB Output is correct
2 Correct 878 ms 48688 KB Output is correct
3 Correct 651 ms 16524 KB Output is correct
4 Correct 856 ms 48656 KB Output is correct
5 Correct 806 ms 48504 KB Output is correct
6 Correct 515 ms 15296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 276 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 392 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 4 ms 716 KB Output is correct
20 Correct 4 ms 720 KB Output is correct
21 Correct 4 ms 716 KB Output is correct
22 Correct 13 ms 1240 KB Output is correct
23 Correct 16 ms 1228 KB Output is correct
24 Correct 13 ms 1192 KB Output is correct
25 Correct 12 ms 1240 KB Output is correct
26 Correct 14 ms 1184 KB Output is correct
27 Correct 8 ms 1100 KB Output is correct
28 Correct 8 ms 1100 KB Output is correct
29 Correct 8 ms 1080 KB Output is correct
30 Correct 29 ms 2116 KB Output is correct
31 Correct 29 ms 2084 KB Output is correct
32 Correct 27 ms 2076 KB Output is correct
33 Correct 73 ms 5544 KB Output is correct
34 Correct 75 ms 5528 KB Output is correct
35 Correct 84 ms 5576 KB Output is correct
36 Correct 446 ms 16444 KB Output is correct
37 Correct 412 ms 16672 KB Output is correct
38 Correct 463 ms 16616 KB Output is correct
39 Correct 452 ms 9132 KB Output is correct
40 Correct 434 ms 9344 KB Output is correct
41 Correct 425 ms 9152 KB Output is correct
42 Correct 251 ms 7180 KB Output is correct
43 Correct 241 ms 15584 KB Output is correct
44 Correct 233 ms 15812 KB Output is correct
45 Correct 238 ms 15644 KB Output is correct
46 Correct 227 ms 15728 KB Output is correct
47 Correct 270 ms 15664 KB Output is correct
48 Correct 232 ms 15556 KB Output is correct
49 Correct 232 ms 15632 KB Output is correct
50 Correct 265 ms 15696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 276 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 392 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 4 ms 716 KB Output is correct
20 Correct 4 ms 720 KB Output is correct
21 Correct 4 ms 716 KB Output is correct
22 Correct 13 ms 1240 KB Output is correct
23 Correct 16 ms 1228 KB Output is correct
24 Correct 13 ms 1192 KB Output is correct
25 Correct 12 ms 1240 KB Output is correct
26 Correct 14 ms 1184 KB Output is correct
27 Correct 240 ms 16124 KB Output is correct
28 Correct 245 ms 16072 KB Output is correct
29 Correct 256 ms 16032 KB Output is correct
30 Correct 237 ms 16020 KB Output is correct
31 Correct 803 ms 16348 KB Output is correct
32 Correct 1280 ms 25852 KB Output is correct
33 Correct 916 ms 16880 KB Output is correct
34 Correct 935 ms 18500 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 484 ms 16736 KB Output is correct
37 Correct 1747 ms 48520 KB Output is correct
38 Correct 1839 ms 48468 KB Output is correct
39 Correct 1849 ms 38568 KB Output is correct
40 Correct 689 ms 17056 KB Output is correct
41 Correct 313 ms 9284 KB Output is correct
42 Correct 39 ms 2496 KB Output is correct
43 Correct 2107 ms 46816 KB Output is correct
44 Correct 1773 ms 32048 KB Output is correct
45 Correct 999 ms 48588 KB Output is correct
46 Correct 878 ms 48688 KB Output is correct
47 Correct 651 ms 16524 KB Output is correct
48 Correct 856 ms 48656 KB Output is correct
49 Correct 806 ms 48504 KB Output is correct
50 Correct 515 ms 15296 KB Output is correct
51 Correct 8 ms 1100 KB Output is correct
52 Correct 8 ms 1100 KB Output is correct
53 Correct 8 ms 1080 KB Output is correct
54 Correct 29 ms 2116 KB Output is correct
55 Correct 29 ms 2084 KB Output is correct
56 Correct 27 ms 2076 KB Output is correct
57 Correct 73 ms 5544 KB Output is correct
58 Correct 75 ms 5528 KB Output is correct
59 Correct 84 ms 5576 KB Output is correct
60 Correct 446 ms 16444 KB Output is correct
61 Correct 412 ms 16672 KB Output is correct
62 Correct 463 ms 16616 KB Output is correct
63 Correct 452 ms 9132 KB Output is correct
64 Correct 434 ms 9344 KB Output is correct
65 Correct 425 ms 9152 KB Output is correct
66 Correct 251 ms 7180 KB Output is correct
67 Correct 241 ms 15584 KB Output is correct
68 Correct 233 ms 15812 KB Output is correct
69 Correct 238 ms 15644 KB Output is correct
70 Correct 227 ms 15728 KB Output is correct
71 Correct 270 ms 15664 KB Output is correct
72 Correct 232 ms 15556 KB Output is correct
73 Correct 232 ms 15632 KB Output is correct
74 Correct 265 ms 15696 KB Output is correct
75 Correct 249 ms 15512 KB Output is correct
76 Correct 275 ms 15792 KB Output is correct
77 Correct 251 ms 15776 KB Output is correct
78 Correct 229 ms 15460 KB Output is correct
79 Correct 424 ms 15832 KB Output is correct
80 Correct 229 ms 15472 KB Output is correct
81 Correct 1835 ms 48676 KB Output is correct
82 Correct 1474 ms 48744 KB Output is correct
83 Correct 1643 ms 48588 KB Output is correct
84 Correct 1803 ms 48492 KB Output is correct
85 Correct 1597 ms 48620 KB Output is correct
86 Correct 1501 ms 48584 KB Output is correct
87 Correct 2017 ms 48028 KB Output is correct
88 Correct 1607 ms 26120 KB Output is correct
89 Correct 1597 ms 26032 KB Output is correct
90 Correct 1563 ms 26032 KB Output is correct
91 Correct 1511 ms 25988 KB Output is correct
92 Correct 1486 ms 26008 KB Output is correct
93 Correct 1352 ms 48516 KB Output is correct
94 Correct 1274 ms 47840 KB Output is correct
95 Correct 1342 ms 48424 KB Output is correct
96 Correct 1190 ms 48220 KB Output is correct
97 Correct 1922 ms 48452 KB Output is correct
98 Correct 1255 ms 27396 KB Output is correct
99 Correct 1246 ms 48148 KB Output is correct
100 Correct 1076 ms 48436 KB Output is correct
101 Correct 1520 ms 31764 KB Output is correct
102 Correct 1226 ms 46584 KB Output is correct
103 Correct 2020 ms 46836 KB Output is correct
104 Correct 1201 ms 54920 KB Output is correct
105 Correct 909 ms 24412 KB Output is correct
106 Correct 802 ms 47928 KB Output is correct
107 Correct 802 ms 48108 KB Output is correct
108 Correct 816 ms 47952 KB Output is correct
109 Correct 800 ms 47984 KB Output is correct
110 Correct 814 ms 47944 KB Output is correct
111 Correct 811 ms 48004 KB Output is correct
112 Correct 842 ms 47848 KB Output is correct
113 Correct 821 ms 48012 KB Output is correct
114 Correct 810 ms 47948 KB Output is correct
115 Correct 816 ms 48196 KB Output is correct
116 Correct 790 ms 48136 KB Output is correct