# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
475173 | 2021-09-21T10:33:50 Z | khr03ae | Circle selection (APIO18_circle_selection) | C++14 | 195 ms | 15196 KB |
#include <bits/stdc++.h> using namespace std; typedef long long i64; const int MAX = 3e5 + 9; struct Circle { int x, y; int radius; int index; } circles[MAX]; int N, par[MAX]; bool deleted[MAX]; void init() { for (int i = 0; i < N; ++i) { par[i] = i; deleted[i] = false; } } bool cmp(Circle& a, Circle &b) { if (a.radius == b.radius) return a.index < b.index; return a.radius > b.radius; } bool intercept(Circle& a, Circle& b) { int dx = a.x - b.x; int dy = a.y - b.y; i64 dist2 = dx * dx * 1LL + dy * dy * 1LL; i64 r2 = (a.radius * 1LL + b.radius * 1LL) * (a.radius * 1LL + b.radius * 1LL) * 1LL; if (dist2 <= r2) { return true; } else { return false; } } int main() { scanf("%d", &N); for (int i = 0; i < N; ++i) { scanf("%d%d%d", &circles[i].x, &circles[i].y, &circles[i].radius); circles[i].index = i; } sort(circles, circles + N, cmp); init(); // for (int i = 0; i < N; ++i) { // printf("%d %d %d %d\n", circles[i].x, circles[i].y, circles[i].radius, circles[i].index); // } for (int i = 0; i < N; ++i) { int u = circles[i].index; if (deleted[u]) continue; for (int j = i + 1; j < N; ++j) { int v = circles[j].index; if (intercept(circles[i], circles[j]) && !deleted[v]) { par[v] = u; deleted[v] = true; } } deleted[u] = true; } for (int i = 0; i < N; ++i) { printf("%d ", par[i] + 1); } printf("\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 177 ms | 15196 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 195 ms | 15004 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |