제출 #710018

#제출 시각아이디문제언어결과실행 시간메모리
710018vjudge1원 고르기 (APIO18_circle_selection)C++17
7 / 100
3078 ms37336 KiB
/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/

#include <bits/stdc++.h>
#define endl '\n'

#define int long long

using namespace std;

const int N = 3e5 + 5;
const long long INF = 1e18 + 7;
const int MAXA = 1e9;
const int B = sqrt(N) + 5;

array<int, 3> a[N];
set <array<int, 3>> s;
int ans[N];
bool f[N];

int dist(pair<int, int> a, pair<int, int> b){
    int h1 = a.first - b.first;
    int h2 = a.second - b.second;
    return h1 * h1 + h2 * h2;
}

bool isintersect(array<int, 3> a, array<int, 3> b){
    pair<int, int> a1 = {a[0], a[1]};
    pair<int, int> b1 = {b[0], b[1]};
    return dist(a1, b1) <= (a[2] + b[2]) * (a[2] + b[2]);
}

void solve()
{
    int n; cin >> n;
    for(int i = 1; i <= n; ++i){
        int x, y, r; cin >> x >> y >> r;
        a[i] = {x, y, r};
        s.insert({-r, r, i});
    }

    while (!s.empty()){
        array<int, 3> state = *s.begin();
        int id = state[2];

        s.erase(state);

        ans[id] = id;

        for(int i = 1; i <= n; ++i){
            if (!ans[i]){
                if (isintersect(a[i], a[id])){
                    ans[i] = id;
                    s.erase({-a[i][2], a[i][2], i});
                }
            }
        }
    }

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

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

    // freopen("codeforces.inp","r",stdin);
    // freopen("codeforces.out","w",stdout);

    int t = 1; // cin >> t;
    while (t--)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...