답안 #1043448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043448 2024-08-04T09:38:29 Z vjudge1 원 고르기 (APIO18_circle_selection) C++17
19 / 100
839 ms 61484 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll N = 3e5 + 10;
ll n, a[N][3], par[N];

ll dist(ll a, ll b, ll x, ll y){
    return ((x - a) * (x - a) + (y - b) * (y - b));
}

int main(){
    cin >> n;
    for (ll i = 1; i <= n; i ++)
        for (ll j = 0; j < 3; j ++)
            cin >> a[i][j];

    if (n <= 5000){
        while (1){
            ll mx = -1;
            for (ll i = 1; i <= n; i ++)
                if (!par[i] and (mx == -1 or a[i][2] > a[mx][2]))
                    mx = i;

            if (mx == -1) break;

            for (ll i = 1; i <= n; i ++)
                if (!par[i] and dist(a[i][0], a[i][1], a[mx][0], a[mx][1]) <= (a[i][2] + a[mx][2]) * (a[i][2] + a[mx][2]))
                    par[i] = mx;
        }

        for (ll i = 1; i <= n; i ++)
            cout << par[i] << " ";
        cout << endl;
        return 0;
    }

    set<pair<int, int>> st, rem;
    for (int i = 1; i <= n; i ++){
        st.insert({a[i][0] + a[i][2], i});
        st.insert({a[i][0] - a[i][2], i});
        rem.insert({-a[i][2], i});
    }

    while (rem.size()){
        int c = (*rem.begin()).second;
        rem.erase(rem.begin());

        if (par[c])
            continue;

        auto it = st.lower_bound({a[c][0] + a[c][2], n});
        while (it == st.end() or (*it).first > (a[c][0] + a[c][2]))
            it--;

        vector<int> done;
        while (1){
            int i = (*it).second;
            if (dist(a[i][0], a[i][1], a[c][0], a[c][1]) <= (a[i][2] + a[c][2]) * (a[i][2] + a[c][2])){
                par[i] = c;
                done.push_back(i);
            }
            else
                break;

            if (it == st.begin()) break;
            it--;
        }

        for (int i : done){
            st.erase({a[i][0] + a[i][2], i});
            st.erase({a[i][0] - a[i][2], i});
        }
    }

    for (int i = 1; i <= n; i ++)
        cout << par[i] << " ";
    cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 4 ms 2492 KB Output is correct
21 Correct 5 ms 2392 KB Output is correct
22 Correct 67 ms 2520 KB Output is correct
23 Correct 68 ms 2392 KB Output is correct
24 Correct 67 ms 2396 KB Output is correct
25 Correct 71 ms 2392 KB Output is correct
26 Correct 67 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 805 ms 54276 KB Output is correct
2 Correct 829 ms 61136 KB Output is correct
3 Correct 836 ms 61484 KB Output is correct
4 Correct 839 ms 61100 KB Output is correct
5 Correct 594 ms 58524 KB Output is correct
6 Correct 639 ms 58708 KB Output is correct
7 Correct 660 ms 58708 KB Output is correct
8 Correct 649 ms 58540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 208 ms 19796 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 687 ms 54008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 4 ms 2492 KB Output is correct
21 Correct 5 ms 2392 KB Output is correct
22 Correct 67 ms 2520 KB Output is correct
23 Correct 68 ms 2392 KB Output is correct
24 Correct 67 ms 2396 KB Output is correct
25 Correct 71 ms 2392 KB Output is correct
26 Correct 67 ms 2396 KB Output is correct
27 Incorrect 17 ms 3932 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 4 ms 2492 KB Output is correct
21 Correct 5 ms 2392 KB Output is correct
22 Correct 67 ms 2520 KB Output is correct
23 Correct 68 ms 2392 KB Output is correct
24 Correct 67 ms 2396 KB Output is correct
25 Correct 71 ms 2392 KB Output is correct
26 Correct 67 ms 2396 KB Output is correct
27 Correct 805 ms 54276 KB Output is correct
28 Correct 829 ms 61136 KB Output is correct
29 Correct 836 ms 61484 KB Output is correct
30 Correct 839 ms 61100 KB Output is correct
31 Correct 594 ms 58524 KB Output is correct
32 Correct 639 ms 58708 KB Output is correct
33 Correct 660 ms 58708 KB Output is correct
34 Correct 649 ms 58540 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Incorrect 208 ms 19796 KB Output isn't correct
37 Halted 0 ms 0 KB -