답안 #1105117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1105117 2024-10-25T12:49:36 Z sqwiijqk 원 고르기 (APIO18_circle_selection) C++17
49 / 100
3000 ms 242872 KB
#include <bits/stdc++.h>
#include <experimental/random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <windows.h>
// #pragma comment(lib, "shell32")
// ShellExecute(0, "open", your_url, NULL, NULL, SW_SHOWDEFAULT)

using namespace std;
using namespace __gnu_pbds;

using ld = long double;
using ll = long long;
using ull = unsigned long long;
const int MOD = 998244353;
const int INF = 1e9;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

void solve();

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int qwerty = 1;
    // cin >> qwerty;
    while (qwerty--) {
        solve();
    }
}

struct circle {
    int x, y, r, ind;
};

bool cmp(circle a, circle b) {
    return a.r > b.r || (a.r == b.r && a.ind < b.ind);
}

bool per(circle a, circle b) {
    return 1ll * (a.x - b.x) * (a.x - b.x) + 1ll * (a.y - b.y) * (a.y - b.y) <= 1ll * (a.r + b.r) * (a.r + b.r);
}

void solve() {
    int n;
    cin >> n;
    vector<circle> cs(n);
    for (int i = 0; i < n; i++) {
        cin >> cs[i].x >> cs[i].y >> cs[i].r;
        cs[i].ind = i;
    }
    sort(cs.begin(), cs.end(), cmp);
    vector<int> ans(n, -1);
    for (int for_r = 30; for_r >= 0; for_r--) {
        int r = (1 << for_r);
        map<pair<int, int>, vector<int>> mp;
        for (int i = 0; i < n; i++) {
            if (ans[cs[i].ind] == -1) {
                mp[{cs[i].x / r, cs[i].y / r}].push_back(i);
            }
        }
        for (int i = 0; i < n; i++) {
            if (cs[i].r < r / 2 || cs[i].r > r || ans[cs[i].ind] != -1) continue;
            for (int x = cs[i].x / r - 2; x <= cs[i].x / r + 2; x++) {
                for (int y = cs[i].y / r - 2; y <= cs[i].y / r + 2; y++) {
                    for (int j: mp[{x, y}]) {
                        if (ans[cs[j].ind] == -1 && per(cs[i], cs[j])) {
                            ans[cs[j].ind] = cs[i].ind;
                        }
                    }
                }
            }
        }
    }
    for (int i: ans) {
        cout << i + 1 << ' ';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 4 ms 760 KB Output is correct
20 Correct 3 ms 592 KB Output is correct
21 Correct 3 ms 644 KB Output is correct
22 Correct 36 ms 4944 KB Output is correct
23 Correct 39 ms 5328 KB Output is correct
24 Correct 36 ms 4188 KB Output is correct
25 Correct 39 ms 4936 KB Output is correct
26 Correct 37 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 16068 KB Output is correct
2 Correct 140 ms 17064 KB Output is correct
3 Correct 141 ms 16800 KB Output is correct
4 Correct 136 ms 16528 KB Output is correct
5 Correct 383 ms 16648 KB Output is correct
6 Correct 1444 ms 64612 KB Output is correct
7 Correct 400 ms 18780 KB Output is correct
8 Correct 577 ms 28948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1119 ms 89796 KB Output is correct
3 Execution timed out 3068 ms 242872 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3057 ms 208692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 4 ms 760 KB Output is correct
20 Correct 3 ms 592 KB Output is correct
21 Correct 3 ms 644 KB Output is correct
22 Correct 36 ms 4944 KB Output is correct
23 Correct 39 ms 5328 KB Output is correct
24 Correct 36 ms 4188 KB Output is correct
25 Correct 39 ms 4936 KB Output is correct
26 Correct 37 ms 5212 KB Output is correct
27 Correct 6 ms 1104 KB Output is correct
28 Correct 6 ms 1116 KB Output is correct
29 Correct 6 ms 1120 KB Output is correct
30 Correct 76 ms 10920 KB Output is correct
31 Correct 84 ms 10824 KB Output is correct
32 Correct 76 ms 8312 KB Output is correct
33 Correct 49 ms 6208 KB Output is correct
34 Correct 49 ms 6096 KB Output is correct
35 Correct 50 ms 6580 KB Output is correct
36 Correct 1319 ms 97716 KB Output is correct
37 Correct 1324 ms 86216 KB Output is correct
38 Correct 1194 ms 99060 KB Output is correct
39 Correct 287 ms 12028 KB Output is correct
40 Correct 283 ms 12172 KB Output is correct
41 Correct 296 ms 11932 KB Output is correct
42 Correct 208 ms 11420 KB Output is correct
43 Correct 1119 ms 178572 KB Output is correct
44 Correct 1085 ms 178756 KB Output is correct
45 Correct 1150 ms 178556 KB Output is correct
46 Correct 1056 ms 178808 KB Output is correct
47 Correct 1138 ms 179032 KB Output is correct
48 Correct 1118 ms 179000 KB Output is correct
49 Correct 1054 ms 179088 KB Output is correct
50 Correct 996 ms 178768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 4 ms 760 KB Output is correct
20 Correct 3 ms 592 KB Output is correct
21 Correct 3 ms 644 KB Output is correct
22 Correct 36 ms 4944 KB Output is correct
23 Correct 39 ms 5328 KB Output is correct
24 Correct 36 ms 4188 KB Output is correct
25 Correct 39 ms 4936 KB Output is correct
26 Correct 37 ms 5212 KB Output is correct
27 Correct 143 ms 16068 KB Output is correct
28 Correct 140 ms 17064 KB Output is correct
29 Correct 141 ms 16800 KB Output is correct
30 Correct 136 ms 16528 KB Output is correct
31 Correct 383 ms 16648 KB Output is correct
32 Correct 1444 ms 64612 KB Output is correct
33 Correct 400 ms 18780 KB Output is correct
34 Correct 577 ms 28948 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1119 ms 89796 KB Output is correct
37 Execution timed out 3068 ms 242872 KB Time limit exceeded
38 Halted 0 ms 0 KB -