# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
169769 | 2019-12-22T19:12:58 Z | ZwariowanyMarcin | 원 고르기 (APIO18_circle_selection) | C++14 | 3000 ms | 351016 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(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
# | 결과 | 실행 시간 | 메모리 | 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 | 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 | 376 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 | 632 KB | Output is correct |
20 | Correct | 6 ms | 632 KB | Output is correct |
21 | Correct | 6 ms | 632 KB | Output is correct |
22 | Correct | 60 ms | 5844 KB | Output is correct |
23 | Correct | 63 ms | 5752 KB | Output is correct |
24 | Correct | 59 ms | 5880 KB | Output is correct |
25 | Correct | 58 ms | 5880 KB | Output is correct |
26 | Correct | 58 ms | 5880 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 229 ms | 10952 KB | Output is correct |
2 | Correct | 235 ms | 10716 KB | Output is correct |
3 | Correct | 228 ms | 10316 KB | Output is correct |
4 | Correct | 226 ms | 10440 KB | Output is correct |
5 | Correct | 334 ms | 13004 KB | Output is correct |
6 | Correct | 1909 ms | 82304 KB | Output is correct |
7 | Correct | 472 ms | 17484 KB | Output is correct |
8 | Correct | 737 ms | 28204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2051 ms | 106208 KB | Output is correct |
3 | Execution timed out | 3045 ms | 318464 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3051 ms | 351016 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 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 | 376 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 | 632 KB | Output is correct |
20 | Correct | 6 ms | 632 KB | Output is correct |
21 | Correct | 6 ms | 632 KB | Output is correct |
22 | Correct | 60 ms | 5844 KB | Output is correct |
23 | Correct | 63 ms | 5752 KB | Output is correct |
24 | Correct | 59 ms | 5880 KB | Output is correct |
25 | Correct | 58 ms | 5880 KB | Output is correct |
26 | Correct | 58 ms | 5880 KB | Output is correct |
27 | Correct | 10 ms | 760 KB | Output is correct |
28 | Correct | 10 ms | 632 KB | Output is correct |
29 | Correct | 10 ms | 632 KB | Output is correct |
30 | Correct | 140 ms | 11052 KB | Output is correct |
31 | Correct | 134 ms | 11004 KB | Output is correct |
32 | Correct | 133 ms | 11128 KB | Output is correct |
33 | Correct | 82 ms | 3812 KB | Output is correct |
34 | Correct | 84 ms | 3684 KB | Output is correct |
35 | Correct | 89 ms | 3556 KB | Output is correct |
36 | Correct | 1870 ms | 108332 KB | Output is correct |
37 | Correct | 1914 ms | 107824 KB | Output is correct |
38 | Correct | 1899 ms | 107572 KB | Output is correct |
39 | Correct | 811 ms | 30764 KB | Output is correct |
40 | Correct | 804 ms | 30676 KB | Output is correct |
41 | Correct | 794 ms | 30520 KB | Output is correct |
42 | Correct | 396 ms | 14144 KB | Output is correct |
43 | Correct | 1457 ms | 176296 KB | Output is correct |
44 | Correct | 1437 ms | 176580 KB | Output is correct |
45 | Correct | 1383 ms | 176440 KB | Output is correct |
46 | Correct | 1379 ms | 176620 KB | Output is correct |
47 | Correct | 1387 ms | 176776 KB | Output is correct |
48 | Correct | 1483 ms | 176728 KB | Output is correct |
49 | Correct | 1494 ms | 176852 KB | Output is correct |
50 | Correct | 1373 ms | 176612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 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 | 376 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 | 632 KB | Output is correct |
20 | Correct | 6 ms | 632 KB | Output is correct |
21 | Correct | 6 ms | 632 KB | Output is correct |
22 | Correct | 60 ms | 5844 KB | Output is correct |
23 | Correct | 63 ms | 5752 KB | Output is correct |
24 | Correct | 59 ms | 5880 KB | Output is correct |
25 | Correct | 58 ms | 5880 KB | Output is correct |
26 | Correct | 58 ms | 5880 KB | Output is correct |
27 | Correct | 229 ms | 10952 KB | Output is correct |
28 | Correct | 235 ms | 10716 KB | Output is correct |
29 | Correct | 228 ms | 10316 KB | Output is correct |
30 | Correct | 226 ms | 10440 KB | Output is correct |
31 | Correct | 334 ms | 13004 KB | Output is correct |
32 | Correct | 1909 ms | 82304 KB | Output is correct |
33 | Correct | 472 ms | 17484 KB | Output is correct |
34 | Correct | 737 ms | 28204 KB | Output is correct |
35 | Correct | 2 ms | 376 KB | Output is correct |
36 | Correct | 2051 ms | 106208 KB | Output is correct |
37 | Execution timed out | 3045 ms | 318464 KB | Time limit exceeded |
38 | Halted | 0 ms | 0 KB | - |