답안 #456162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
456162 2021-08-06T07:39:15 Z prvocislo 원 고르기 (APIO18_circle_selection) C++17
87 / 100
3000 ms 25176 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
typedef long long ll;
using namespace std;

const int maxn = 3e5 + 5, logn = 30; 
const ll maxi = 1e9 + 5;
struct circle { ll x, y, r; };
vector<circle> c(maxn);
bool in(const int& a, const int& b)
{
    return (c[a].r + c[b].r) * (c[a].r + c[b].r) >= (c[a].x - c[b].x) * (c[a].x - c[b].x) + (c[a].y - c[b].y) * (c[a].y - c[b].y);
}
bool cmp(const int& a, const int& b)
{
    return (c[a].r == c[b].r ? a < b : c[a].r > c[b].r);
}
vector<pair<pair<int, int>, int> > o;
vector<int> ans(maxn, -1), ord(maxn, -1);
int n, r;
void process(int i)
{
    for (int l = -2; l <= 2; l++)
    {
        int x = (c[i].x >> r) + l;
        int y1 = max(-maxi, (((ll)c[i].y) >> ((ll)r)) - (1ll << ((ll)(r + 1))));
        int y2 = min( maxi, (((ll)c[i].y) >> ((ll)r)) + (1ll << ((ll)(r + 1))));
        auto it = lower_bound(o.begin(), o.end(), make_pair( make_pair(x, y1), -1 ));
        while (it != o.end() && it->first <= make_pair(x, y2))
        {
            if (ans[it->second] == -1 && in(it->second, i)) ans[it->second] = i;
            it++;
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> c[i].x >> c[i].y >> c[i].r, ord[i] = i;
    sort(ord.begin(), ord.begin() + n, cmp);
    int id = 0;
    for (r = logn; r >= 0; r--)
    {
        o.clear();
        for (int i = 0; i < n; i++) if (ans[i] == -1)
            o.push_back({ {c[i].x >> r, c[i].y >> r}, i });
        sort(o.begin(), o.end());
        while (id != n && (!r || c[ord[id]].r >= (1 << (r - 1))))
        {
            if (ans[ord[id]] == -1) process(ord[id]);
            id++;
        }
    }
    for (int i = 0; i < n; i++) cout << ans[i]+1 << " ";
    cout << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9676 KB Output is correct
2 Correct 5 ms 9712 KB Output is correct
3 Correct 5 ms 9716 KB Output is correct
4 Correct 5 ms 9676 KB Output is correct
5 Correct 6 ms 9712 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 6 ms 9616 KB Output is correct
8 Correct 7 ms 9676 KB Output is correct
9 Correct 5 ms 9676 KB Output is correct
10 Correct 5 ms 9720 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 5 ms 9676 KB Output is correct
13 Correct 6 ms 9676 KB Output is correct
14 Correct 6 ms 9676 KB Output is correct
15 Correct 6 ms 9716 KB Output is correct
16 Correct 7 ms 9732 KB Output is correct
17 Correct 6 ms 9772 KB Output is correct
18 Correct 7 ms 9676 KB Output is correct
19 Correct 9 ms 9992 KB Output is correct
20 Correct 8 ms 9988 KB Output is correct
21 Correct 9 ms 9984 KB Output is correct
22 Correct 20 ms 10004 KB Output is correct
23 Correct 22 ms 10004 KB Output is correct
24 Correct 22 ms 10016 KB Output is correct
25 Correct 19 ms 10008 KB Output is correct
26 Correct 19 ms 10012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 22736 KB Output is correct
2 Correct 345 ms 22620 KB Output is correct
3 Correct 328 ms 22720 KB Output is correct
4 Correct 261 ms 22684 KB Output is correct
5 Correct 962 ms 20596 KB Output is correct
6 Correct 1142 ms 20628 KB Output is correct
7 Correct 995 ms 20660 KB Output is correct
8 Correct 1025 ms 20636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9676 KB Output is correct
2 Correct 384 ms 14296 KB Output is correct
3 Correct 1635 ms 24184 KB Output is correct
4 Correct 1582 ms 24088 KB Output is correct
5 Correct 1970 ms 24012 KB Output is correct
6 Correct 630 ms 17208 KB Output is correct
7 Correct 270 ms 13612 KB Output is correct
8 Correct 55 ms 10632 KB Output is correct
9 Correct 1807 ms 24080 KB Output is correct
10 Correct 2718 ms 24372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1328 ms 23876 KB Output is correct
2 Correct 1562 ms 22964 KB Output is correct
3 Correct 1510 ms 24396 KB Output is correct
4 Correct 1282 ms 23476 KB Output is correct
5 Correct 1295 ms 23504 KB Output is correct
6 Correct 1360 ms 24580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9676 KB Output is correct
2 Correct 5 ms 9712 KB Output is correct
3 Correct 5 ms 9716 KB Output is correct
4 Correct 5 ms 9676 KB Output is correct
5 Correct 6 ms 9712 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 6 ms 9616 KB Output is correct
8 Correct 7 ms 9676 KB Output is correct
9 Correct 5 ms 9676 KB Output is correct
10 Correct 5 ms 9720 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 5 ms 9676 KB Output is correct
13 Correct 6 ms 9676 KB Output is correct
14 Correct 6 ms 9676 KB Output is correct
15 Correct 6 ms 9716 KB Output is correct
16 Correct 7 ms 9732 KB Output is correct
17 Correct 6 ms 9772 KB Output is correct
18 Correct 7 ms 9676 KB Output is correct
19 Correct 9 ms 9992 KB Output is correct
20 Correct 8 ms 9988 KB Output is correct
21 Correct 9 ms 9984 KB Output is correct
22 Correct 20 ms 10004 KB Output is correct
23 Correct 22 ms 10004 KB Output is correct
24 Correct 22 ms 10016 KB Output is correct
25 Correct 19 ms 10008 KB Output is correct
26 Correct 19 ms 10012 KB Output is correct
27 Correct 15 ms 10284 KB Output is correct
28 Correct 14 ms 10276 KB Output is correct
29 Correct 12 ms 10276 KB Output is correct
30 Correct 38 ms 10240 KB Output is correct
31 Correct 37 ms 10244 KB Output is correct
32 Correct 36 ms 10248 KB Output is correct
33 Correct 84 ms 14676 KB Output is correct
34 Correct 96 ms 14676 KB Output is correct
35 Correct 99 ms 14548 KB Output is correct
36 Correct 379 ms 14064 KB Output is correct
37 Correct 387 ms 14156 KB Output is correct
38 Correct 385 ms 14196 KB Output is correct
39 Correct 556 ms 12628 KB Output is correct
40 Correct 553 ms 12608 KB Output is correct
41 Correct 547 ms 12612 KB Output is correct
42 Correct 581 ms 13156 KB Output is correct
43 Correct 375 ms 14140 KB Output is correct
44 Correct 381 ms 14136 KB Output is correct
45 Correct 429 ms 14132 KB Output is correct
46 Correct 401 ms 14128 KB Output is correct
47 Correct 376 ms 14172 KB Output is correct
48 Correct 388 ms 14128 KB Output is correct
49 Correct 375 ms 14148 KB Output is correct
50 Correct 377 ms 14108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9676 KB Output is correct
2 Correct 5 ms 9712 KB Output is correct
3 Correct 5 ms 9716 KB Output is correct
4 Correct 5 ms 9676 KB Output is correct
5 Correct 6 ms 9712 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 6 ms 9616 KB Output is correct
8 Correct 7 ms 9676 KB Output is correct
9 Correct 5 ms 9676 KB Output is correct
10 Correct 5 ms 9720 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 5 ms 9676 KB Output is correct
13 Correct 6 ms 9676 KB Output is correct
14 Correct 6 ms 9676 KB Output is correct
15 Correct 6 ms 9716 KB Output is correct
16 Correct 7 ms 9732 KB Output is correct
17 Correct 6 ms 9772 KB Output is correct
18 Correct 7 ms 9676 KB Output is correct
19 Correct 9 ms 9992 KB Output is correct
20 Correct 8 ms 9988 KB Output is correct
21 Correct 9 ms 9984 KB Output is correct
22 Correct 20 ms 10004 KB Output is correct
23 Correct 22 ms 10004 KB Output is correct
24 Correct 22 ms 10016 KB Output is correct
25 Correct 19 ms 10008 KB Output is correct
26 Correct 19 ms 10012 KB Output is correct
27 Correct 287 ms 22736 KB Output is correct
28 Correct 345 ms 22620 KB Output is correct
29 Correct 328 ms 22720 KB Output is correct
30 Correct 261 ms 22684 KB Output is correct
31 Correct 962 ms 20596 KB Output is correct
32 Correct 1142 ms 20628 KB Output is correct
33 Correct 995 ms 20660 KB Output is correct
34 Correct 1025 ms 20636 KB Output is correct
35 Correct 5 ms 9676 KB Output is correct
36 Correct 384 ms 14296 KB Output is correct
37 Correct 1635 ms 24184 KB Output is correct
38 Correct 1582 ms 24088 KB Output is correct
39 Correct 1970 ms 24012 KB Output is correct
40 Correct 630 ms 17208 KB Output is correct
41 Correct 270 ms 13612 KB Output is correct
42 Correct 55 ms 10632 KB Output is correct
43 Correct 1807 ms 24080 KB Output is correct
44 Correct 2718 ms 24372 KB Output is correct
45 Correct 1328 ms 23876 KB Output is correct
46 Correct 1562 ms 22964 KB Output is correct
47 Correct 1510 ms 24396 KB Output is correct
48 Correct 1282 ms 23476 KB Output is correct
49 Correct 1295 ms 23504 KB Output is correct
50 Correct 1360 ms 24580 KB Output is correct
51 Correct 15 ms 10284 KB Output is correct
52 Correct 14 ms 10276 KB Output is correct
53 Correct 12 ms 10276 KB Output is correct
54 Correct 38 ms 10240 KB Output is correct
55 Correct 37 ms 10244 KB Output is correct
56 Correct 36 ms 10248 KB Output is correct
57 Correct 84 ms 14676 KB Output is correct
58 Correct 96 ms 14676 KB Output is correct
59 Correct 99 ms 14548 KB Output is correct
60 Correct 379 ms 14064 KB Output is correct
61 Correct 387 ms 14156 KB Output is correct
62 Correct 385 ms 14196 KB Output is correct
63 Correct 556 ms 12628 KB Output is correct
64 Correct 553 ms 12608 KB Output is correct
65 Correct 547 ms 12612 KB Output is correct
66 Correct 581 ms 13156 KB Output is correct
67 Correct 375 ms 14140 KB Output is correct
68 Correct 381 ms 14136 KB Output is correct
69 Correct 429 ms 14132 KB Output is correct
70 Correct 401 ms 14128 KB Output is correct
71 Correct 376 ms 14172 KB Output is correct
72 Correct 388 ms 14128 KB Output is correct
73 Correct 375 ms 14148 KB Output is correct
74 Correct 377 ms 14108 KB Output is correct
75 Correct 294 ms 25176 KB Output is correct
76 Correct 341 ms 24684 KB Output is correct
77 Correct 310 ms 24984 KB Output is correct
78 Correct 246 ms 25012 KB Output is correct
79 Correct 520 ms 24788 KB Output is correct
80 Correct 241 ms 25016 KB Output is correct
81 Correct 1549 ms 24020 KB Output is correct
82 Correct 1426 ms 23888 KB Output is correct
83 Correct 1390 ms 23740 KB Output is correct
84 Correct 1917 ms 24380 KB Output is correct
85 Correct 1451 ms 23908 KB Output is correct
86 Correct 1417 ms 23888 KB Output is correct
87 Execution timed out 3075 ms 23988 KB Time limit exceeded
88 Halted 0 ms 0 KB -