# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169768 | 2019-12-22T19:09:56 Z | ZwariowanyMarcin | Circle selection (APIO18_circle_selection) | C++14 | 3000 ms | 356244 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define ss(x) (int) x.size() #define pb push_back #define ll long long #define cat(x) cerr << #x << " = " << x << endl #define FOR(i, n) for(int i = 0; i < n; ++i) using namespace std; const int INF = 2e9; struct circle { int x, y, r; }; bool inter(circle a, circle b) { return 1ll * (a.x - b.x) * (a.x - b.x) + 1ll * (a.y - b.y) * (a.y - b.y) <= 1ll * (a.r + b.r) * (a.r + b.r); } map <pair<int, int>, vector <int> > mapa; int n; circle t[300005]; int cur = INF; vector <int> v; int ans[300005]; void go() { mapa.clear(); for(int i = 1; i <= n; ++i) { if(ans[i]) continue; mapa[mp(t[i].x / cur, t[i].y / cur)].pb(i); } } vector <int> wywal; void solve(int x, int y, int id) { for(int i = 0; i < ss(mapa[mp(x, y)]); ++i) { auto it = mapa[mp(x, y)][i]; if(ans[it]) continue; if(inter(t[id], t[it])) { ans[it] = id; } else { wywal.pb(id); } } mapa[mp(x, y)] = wywal; wywal.clear(); } int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d %d %d", &t[i].x, &t[i].y, &t[i].r); t[i].x += 1000000000; t[i].y += 1000000000; v.pb(i); } sort(v.begin(), v.end(), [](int a, int b) { if(t[a].r != t[b].r) return t[a].r < t[b].r; return a > b; }); go(); for(int i = n - 1; 0 <= i; --i) { int ja = v[i]; if(!ans[ja]) { if(2 * t[ja].r < cur) { cur = t[ja].r; go(); } for(int x = t[ja].x / cur - 2; x <= t[ja].x / cur + 2; ++x) for(int y = t[ja].y / cur - 2; y <= t[ja].y / cur + 2; ++y) solve(x, y, ja); } } for(int i = 1; i <= n; ++i) printf("%d ", ans[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 472 KB | Output is correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 232 ms | 10992 KB | Output is correct |
2 | Incorrect | 285 ms | 10956 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3103 ms | 356244 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 472 KB | Output is correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 472 KB | Output is correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |