# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169770 | 2019-12-22T19:15:12 Z | ZwariowanyMarcin | Circle selection (APIO18_circle_selection) | C++14 | 3000 ms | 374804 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(const circle &a, const 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; inline void solve(const int &x, const int &y, const int &id) { for(auto it : mapa[mp(x, y)]) { if(ans[it]) continue; if(inter(t[id], t[it])) { ans[it] = id; } else { wywal.pb(it); } } 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 | 376 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 | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 504 KB | Output is correct |
13 | Correct | 3 ms | 504 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 504 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 3 ms | 376 KB | Output is correct |
18 | Correct | 3 ms | 376 KB | Output is correct |
19 | Correct | 6 ms | 504 KB | Output is correct |
20 | Correct | 6 ms | 504 KB | Output is correct |
21 | Correct | 6 ms | 524 KB | Output is correct |
22 | Correct | 57 ms | 5736 KB | Output is correct |
23 | Correct | 61 ms | 5684 KB | Output is correct |
24 | Correct | 57 ms | 5872 KB | Output is correct |
25 | Correct | 61 ms | 5880 KB | Output is correct |
26 | Correct | 74 ms | 5716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 226 ms | 10824 KB | Output is correct |
2 | Correct | 227 ms | 10696 KB | Output is correct |
3 | Correct | 226 ms | 10240 KB | Output is correct |
4 | Correct | 223 ms | 10320 KB | Output is correct |
5 | Correct | 304 ms | 12756 KB | Output is correct |
6 | Correct | 1772 ms | 82372 KB | Output is correct |
7 | Correct | 407 ms | 17244 KB | Output is correct |
8 | Correct | 652 ms | 27956 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 1937 ms | 106124 KB | Output is correct |
3 | Execution timed out | 3071 ms | 318448 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3053 ms | 374804 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 | 376 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 | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 504 KB | Output is correct |
13 | Correct | 3 ms | 504 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 504 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 3 ms | 376 KB | Output is correct |
18 | Correct | 3 ms | 376 KB | Output is correct |
19 | Correct | 6 ms | 504 KB | Output is correct |
20 | Correct | 6 ms | 504 KB | Output is correct |
21 | Correct | 6 ms | 524 KB | Output is correct |
22 | Correct | 57 ms | 5736 KB | Output is correct |
23 | Correct | 61 ms | 5684 KB | Output is correct |
24 | Correct | 57 ms | 5872 KB | Output is correct |
25 | Correct | 61 ms | 5880 KB | Output is correct |
26 | Correct | 74 ms | 5716 KB | Output is correct |
27 | Correct | 10 ms | 632 KB | Output is correct |
28 | Correct | 10 ms | 632 KB | Output is correct |
29 | Correct | 10 ms | 632 KB | Output is correct |
30 | Correct | 131 ms | 11000 KB | Output is correct |
31 | Correct | 131 ms | 10992 KB | Output is correct |
32 | Correct | 127 ms | 11096 KB | Output is correct |
33 | Correct | 82 ms | 3824 KB | Output is correct |
34 | Correct | 83 ms | 3572 KB | Output is correct |
35 | Correct | 89 ms | 3580 KB | Output is correct |
36 | Correct | 1792 ms | 108340 KB | Output is correct |
37 | Correct | 1791 ms | 107728 KB | Output is correct |
38 | Correct | 1841 ms | 107660 KB | Output is correct |
39 | Correct | 623 ms | 30696 KB | Output is correct |
40 | Correct | 613 ms | 30668 KB | Output is correct |
41 | Correct | 626 ms | 30636 KB | Output is correct |
42 | Correct | 341 ms | 14184 KB | Output is correct |
43 | Correct | 1323 ms | 176304 KB | Output is correct |
44 | Correct | 1326 ms | 176812 KB | Output is correct |
45 | Correct | 1331 ms | 176360 KB | Output is correct |
46 | Correct | 1359 ms | 176612 KB | Output is correct |
47 | Correct | 1338 ms | 176756 KB | Output is correct |
48 | Correct | 1405 ms | 176776 KB | Output is correct |
49 | Correct | 1345 ms | 176712 KB | Output is correct |
50 | Correct | 1386 ms | 176616 KB | Output is correct |
# | 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 | 376 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 | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 504 KB | Output is correct |
13 | Correct | 3 ms | 504 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 504 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 3 ms | 376 KB | Output is correct |
18 | Correct | 3 ms | 376 KB | Output is correct |
19 | Correct | 6 ms | 504 KB | Output is correct |
20 | Correct | 6 ms | 504 KB | Output is correct |
21 | Correct | 6 ms | 524 KB | Output is correct |
22 | Correct | 57 ms | 5736 KB | Output is correct |
23 | Correct | 61 ms | 5684 KB | Output is correct |
24 | Correct | 57 ms | 5872 KB | Output is correct |
25 | Correct | 61 ms | 5880 KB | Output is correct |
26 | Correct | 74 ms | 5716 KB | Output is correct |
27 | Correct | 226 ms | 10824 KB | Output is correct |
28 | Correct | 227 ms | 10696 KB | Output is correct |
29 | Correct | 226 ms | 10240 KB | Output is correct |
30 | Correct | 223 ms | 10320 KB | Output is correct |
31 | Correct | 304 ms | 12756 KB | Output is correct |
32 | Correct | 1772 ms | 82372 KB | Output is correct |
33 | Correct | 407 ms | 17244 KB | Output is correct |
34 | Correct | 652 ms | 27956 KB | Output is correct |
35 | Correct | 2 ms | 376 KB | Output is correct |
36 | Correct | 1937 ms | 106124 KB | Output is correct |
37 | Execution timed out | 3071 ms | 318448 KB | Time limit exceeded |
38 | Halted | 0 ms | 0 KB | - |