# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
475223 | 2021-09-21T14:36:09 Z | khr03ae | Circle selection (APIO18_circle_selection) | C++14 | 254 ms | 24948 KB |
#include <bits/stdc++.h> using namespace std; typedef long long i64; const int MAX = 3e5 + 9; int N, par[MAX]; bool removed[MAX]; struct Circle { i64 x, y; i64 radius; int index; } circles[MAX], sweep[MAX]; pair<int, int> seg[MAX]; bool cmpX(Circle& a, Circle& b) { if (a.x == b.x) return a.radius > b.radius; return a.x < b.x; } bool intercept(Circle& a, Circle& b) { i64 dx = a.x - b.x; i64 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; } } bool cmp(Circle& a, Circle& b) { if (a.radius == b.radius) return a.x < b.x; return a.radius > b.radius; } int main() { scanf("%d", &N); for (int i = 0; i < N; ++i) { scanf("%lld%lld%lld", &circles[i].x, &circles[i].y, &circles[i].radius); circles[i].index = i; } for (int i = 0; i < N; ++i) sweep[i] = circles[i]; sort(sweep, sweep + N, cmpX); int j = 0; for (int i = 1; i < N; ++i) { if (!intercept(sweep[i], sweep[j])) { for (int k = j; k < i; ++k) { int u = sweep[k].index; seg[u].first = j; } j = i; } } for (int i = j; i < N; ++i) { int u = sweep[i].index; seg[u].first = j; } j = 1; for (int i = 0; i < N; ++i) { while (j < N && intercept(sweep[i], sweep[j])) { j += 1; } int u = sweep[i].index; seg[u].second = j - 1; } sort(circles, circles + N, cmp); for (int i = 0; i < N; ++i) removed[i] = false; for (int i = 0; i < N; ++i) { int u = circles[i].index; if (removed[u]) continue; par[u] = u; for (int j = seg[u].first; j <= seg[u].second; ++j) { int v = sweep[j].index; if (removed[v]) continue; par[v] = u; removed[v] = true; } removed[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 | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Incorrect | 1 ms | 204 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 226 ms | 24948 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 | 254 ms | 24848 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Incorrect | 1 ms | 204 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Incorrect | 1 ms | 204 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |