# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
111244 | 2019-05-14T13:16:59 Z | Just_Solve_The_Problem | 원 고르기 (APIO18_circle_selection) | C++11 | 3000 ms | 62944 KB |
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = (int)3e5+ 7; int x[N], y[N], r[N]; int n; int ans[N]; map<pair<int, int>, vector<int>> mp; int pos[N]; int block = 0; set <int> ost; ll sqr(ll x) { return x * x; } ll dist(int x1, int y1, int x2, int y2) { return sqr(x1 - x2) + sqr(y1 - y2); } void rescale() { mp.clear(); for (int to : ost) { mp[{x[to] / block, y[to] / block}].push_back(to); } } main() { iota(pos, pos + N, 0); scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d %d", &x[i], &y[i], &r[i]); ost.insert(i); } sort(pos + 1, pos + n + 1, [&](const int &A, const int &B) { if (r[A] == r[B]) return A < B; return r[A] > r[B]; }); for (int i = 1; i <= n; i++) { if (ans[pos[i]]) continue; if (block == 0 || r[pos[i]] * 2 <= block) { block = r[pos[i]]; rescale(); } for (int cx = x[pos[i]] / block - 2; cx <= x[pos[i]] / block + 2; cx++) { for (int cy = y[pos[i]] / block - 2; cy <= y[pos[i]] / block + 2; cy++) { if (!mp.count({cx, cy})) continue; for (int to : mp[{cx, cy}]) { if (!ans[to] && dist(x[pos[i]], y[pos[i]], x[to], y[to]) <= sqr(r[pos[i]] + r[to])) { ans[to] = pos[i]; ost.erase(to); } } } } } for (int i = 1; i <= n; i++) { printf("%d ", ans[i]); } } /* 11 9 9 3 13 2 3 11 8 3 3 3 3 3 12 3 12 14 3 9 8 3 2 8 3 5 2 3 14 4 3 14 14 3 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1536 KB | Output is correct |
2 | Correct | 3 ms | 1536 KB | Output is correct |
3 | Correct | 3 ms | 1528 KB | Output is correct |
4 | Correct | 3 ms | 1536 KB | Output is correct |
5 | Correct | 3 ms | 1536 KB | Output is correct |
6 | Correct | 3 ms | 1536 KB | Output is correct |
7 | Correct | 4 ms | 1536 KB | Output is correct |
8 | Correct | 3 ms | 1536 KB | Output is correct |
9 | Correct | 4 ms | 1536 KB | Output is correct |
10 | Correct | 3 ms | 1536 KB | Output is correct |
11 | Correct | 2 ms | 1536 KB | Output is correct |
12 | Correct | 3 ms | 1536 KB | Output is correct |
13 | Correct | 3 ms | 1536 KB | Output is correct |
14 | Correct | 3 ms | 1536 KB | Output is correct |
15 | Correct | 4 ms | 1536 KB | Output is correct |
16 | Correct | 5 ms | 1536 KB | Output is correct |
17 | Correct | 4 ms | 1536 KB | Output is correct |
18 | Correct | 4 ms | 1536 KB | Output is correct |
19 | Correct | 8 ms | 1920 KB | Output is correct |
20 | Correct | 7 ms | 1920 KB | Output is correct |
21 | Correct | 7 ms | 1920 KB | Output is correct |
22 | Correct | 25 ms | 2432 KB | Output is correct |
23 | Correct | 21 ms | 2432 KB | Output is correct |
24 | Correct | 21 ms | 2560 KB | Output is correct |
25 | Correct | 17 ms | 2432 KB | Output is correct |
26 | Correct | 18 ms | 2432 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 364 ms | 22596 KB | Output is correct |
2 | Correct | 350 ms | 23196 KB | Output is correct |
3 | Correct | 337 ms | 23532 KB | Output is correct |
4 | Correct | 343 ms | 22608 KB | Output is correct |
5 | Correct | 789 ms | 23068 KB | Output is correct |
6 | Correct | 1530 ms | 38520 KB | Output is correct |
7 | Correct | 742 ms | 24440 KB | Output is correct |
8 | Correct | 948 ms | 28584 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1536 KB | Output is correct |
2 | Correct | 873 ms | 19256 KB | Output is correct |
3 | Execution timed out | 3009 ms | 61332 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2231 ms | 55208 KB | Output is correct |
2 | Correct | 1511 ms | 62420 KB | Output is correct |
3 | Correct | 1076 ms | 40532 KB | Output is correct |
4 | Correct | 1633 ms | 62764 KB | Output is correct |
5 | Correct | 1510 ms | 62944 KB | Output is correct |
6 | Correct | 716 ms | 34080 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1536 KB | Output is correct |
2 | Correct | 3 ms | 1536 KB | Output is correct |
3 | Correct | 3 ms | 1528 KB | Output is correct |
4 | Correct | 3 ms | 1536 KB | Output is correct |
5 | Correct | 3 ms | 1536 KB | Output is correct |
6 | Correct | 3 ms | 1536 KB | Output is correct |
7 | Correct | 4 ms | 1536 KB | Output is correct |
8 | Correct | 3 ms | 1536 KB | Output is correct |
9 | Correct | 4 ms | 1536 KB | Output is correct |
10 | Correct | 3 ms | 1536 KB | Output is correct |
11 | Correct | 2 ms | 1536 KB | Output is correct |
12 | Correct | 3 ms | 1536 KB | Output is correct |
13 | Correct | 3 ms | 1536 KB | Output is correct |
14 | Correct | 3 ms | 1536 KB | Output is correct |
15 | Correct | 4 ms | 1536 KB | Output is correct |
16 | Correct | 5 ms | 1536 KB | Output is correct |
17 | Correct | 4 ms | 1536 KB | Output is correct |
18 | Correct | 4 ms | 1536 KB | Output is correct |
19 | Correct | 8 ms | 1920 KB | Output is correct |
20 | Correct | 7 ms | 1920 KB | Output is correct |
21 | Correct | 7 ms | 1920 KB | Output is correct |
22 | Correct | 25 ms | 2432 KB | Output is correct |
23 | Correct | 21 ms | 2432 KB | Output is correct |
24 | Correct | 21 ms | 2560 KB | Output is correct |
25 | Correct | 17 ms | 2432 KB | Output is correct |
26 | Correct | 18 ms | 2432 KB | Output is correct |
27 | Correct | 12 ms | 2304 KB | Output is correct |
28 | Correct | 12 ms | 2588 KB | Output is correct |
29 | Correct | 12 ms | 2560 KB | Output is correct |
30 | Correct | 45 ms | 3584 KB | Output is correct |
31 | Correct | 52 ms | 3576 KB | Output is correct |
32 | Correct | 46 ms | 3576 KB | Output is correct |
33 | Correct | 112 ms | 12148 KB | Output is correct |
34 | Correct | 124 ms | 12136 KB | Output is correct |
35 | Correct | 112 ms | 11492 KB | Output is correct |
36 | Correct | 801 ms | 21880 KB | Output is correct |
37 | Correct | 876 ms | 22008 KB | Output is correct |
38 | Correct | 874 ms | 22108 KB | Output is correct |
39 | Correct | 721 ms | 19000 KB | Output is correct |
40 | Correct | 631 ms | 18900 KB | Output is correct |
41 | Correct | 617 ms | 18956 KB | Output is correct |
42 | Correct | 558 ms | 20984 KB | Output is correct |
43 | Correct | 494 ms | 21752 KB | Output is correct |
44 | Correct | 459 ms | 21880 KB | Output is correct |
45 | Correct | 448 ms | 21752 KB | Output is correct |
46 | Correct | 461 ms | 21732 KB | Output is correct |
47 | Correct | 464 ms | 21796 KB | Output is correct |
48 | Correct | 492 ms | 21788 KB | Output is correct |
49 | Correct | 488 ms | 21752 KB | Output is correct |
50 | Correct | 463 ms | 21924 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1536 KB | Output is correct |
2 | Correct | 3 ms | 1536 KB | Output is correct |
3 | Correct | 3 ms | 1528 KB | Output is correct |
4 | Correct | 3 ms | 1536 KB | Output is correct |
5 | Correct | 3 ms | 1536 KB | Output is correct |
6 | Correct | 3 ms | 1536 KB | Output is correct |
7 | Correct | 4 ms | 1536 KB | Output is correct |
8 | Correct | 3 ms | 1536 KB | Output is correct |
9 | Correct | 4 ms | 1536 KB | Output is correct |
10 | Correct | 3 ms | 1536 KB | Output is correct |
11 | Correct | 2 ms | 1536 KB | Output is correct |
12 | Correct | 3 ms | 1536 KB | Output is correct |
13 | Correct | 3 ms | 1536 KB | Output is correct |
14 | Correct | 3 ms | 1536 KB | Output is correct |
15 | Correct | 4 ms | 1536 KB | Output is correct |
16 | Correct | 5 ms | 1536 KB | Output is correct |
17 | Correct | 4 ms | 1536 KB | Output is correct |
18 | Correct | 4 ms | 1536 KB | Output is correct |
19 | Correct | 8 ms | 1920 KB | Output is correct |
20 | Correct | 7 ms | 1920 KB | Output is correct |
21 | Correct | 7 ms | 1920 KB | Output is correct |
22 | Correct | 25 ms | 2432 KB | Output is correct |
23 | Correct | 21 ms | 2432 KB | Output is correct |
24 | Correct | 21 ms | 2560 KB | Output is correct |
25 | Correct | 17 ms | 2432 KB | Output is correct |
26 | Correct | 18 ms | 2432 KB | Output is correct |
27 | Correct | 364 ms | 22596 KB | Output is correct |
28 | Correct | 350 ms | 23196 KB | Output is correct |
29 | Correct | 337 ms | 23532 KB | Output is correct |
30 | Correct | 343 ms | 22608 KB | Output is correct |
31 | Correct | 789 ms | 23068 KB | Output is correct |
32 | Correct | 1530 ms | 38520 KB | Output is correct |
33 | Correct | 742 ms | 24440 KB | Output is correct |
34 | Correct | 948 ms | 28584 KB | Output is correct |
35 | Correct | 2 ms | 1536 KB | Output is correct |
36 | Correct | 873 ms | 19256 KB | Output is correct |
37 | Execution timed out | 3009 ms | 61332 KB | Time limit exceeded |
38 | Halted | 0 ms | 0 KB | - |