Submission #49098

#TimeUsernameProblemLanguageResultExecution timeMemory
49098BTheroCircle selection (APIO18_circle_selection)C++17
7 / 100
3048 ms8768 KiB
// Why am I so stupid? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

typedef long long ll;

using namespace std;

const int MAXN = 3e5+5;

struct circle {
    int x, y, r, id;

    circle() {
        x = y = r = id = 0;
    }
} arr[MAXN];

int ans[MAXN];

int n;

bool cmp(circle a, circle b) {
    if (a.r == b.r) {
        return a.id < b.id;
    }

    return a.r > b.r;
}

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

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r);
        arr[i].id = i;
    }

    sort(arr + 1, arr + n + 1, cmp);
    vector <circle> vv;

    for (int i = 1; i <= n; ++i) {
        ans[arr[i].id] = arr[i].id;

        for (circle it : vv) {
            if (inter(arr[i], it)) {
                ans[arr[i].id] = it.id;
                break;
            }
        }

        if (ans[arr[i].id] == arr[i].id) {
            vv.pb(arr[i]);
        }
    }

    for (int i = 1; i <= n; ++i) {
        printf("%d ", ans[i]);
    }
}

int main() {
#ifdef BThero
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // BThero

    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Compilation message (stderr)

circle_selection.cpp: In function 'void solve()':
circle_selection.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
circle_selection.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &arr[i].x, &arr[i].y, &arr[i].r);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...