Submission #265491

# Submission time Handle Problem Language Result Execution time Memory
265491 2020-08-14T22:16:39 Z DS007 Circle selection (APIO18_circle_selection) C++14
0 / 100
3000 ms 22776 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

    circle() {
        x = y = r = i = 0;
    }

    bool operator < (circle c) {
        if (r == c.r)
            return i < c.i;
        return r > c.r;
    }
};

const int N = 3e5;
circle c[N];
bool done[N];
int n, ans[N], x[N], y[N], r[N];

int solveTestCase() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i] >> r[i];

    for (int i = 0; i < n; i++) {
        pair<int, int> best = {1e18, 1e18};
        for (int j = 0; j < n; j++) {
            if (!done[j])
                best = min(best, {-r[j], j});
        }

        if (best.first == 1e18)
            break;
        for (int j = 0,ind = best.second; j < n; j++) {
            if (done[j])
                continue;
            int dist = (x[ind] - x[j]) * (x[ind] - x[j]) + (y[ind] - y[j]) * (y[ind] - y[j]);
            if (dist <= (r[ind] + r[j]) * (r[ind] + r[j]))
                ans[j] = ind + 1;
        }
    }

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


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    //cin >> t;
    while (t--)
        solveTestCase();
}


Compilation message

circle_selection.cpp: In function 'long long int solveTestCase()':
circle_selection.cpp:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
   49 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 22648 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3065 ms 19156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 136 ms 22776 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3073 ms 16888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 22648 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 22648 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -