# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1118322 | 2024-11-25T09:19:18 Z | lmToT27 | 원 고르기 (APIO18_circle_selection) | C++17 | 2188 ms | 63572 KB |
#include <bits/stdc++.h> #define all(dataStructure) dataStructure.begin(),dataStructure.end() using namespace std; typedef long long ll; const int MAX = 3e5 + 3; const ll MOD[] = {1000000007, 998244353}; int n, blockSize = 2e9; int ans[MAX]; int x[MAX], y[MAX], r[MAX]; set <int> S; map <pair <int, int>, vector <int>> block; ll sq(ll x) { return x * x; } ll dist(int i, int j) { return sq(x[i] - x[j]) + sq(y[i] - y[j]); } void rebuild() { block.clear(); for (auto &&i : S) block[{x[i] / blockSize, y[i] / blockSize}].push_back(i); } void Solve() { cin >> n; vector <int> id(n); for (int i = 1; i <= n; i++) { S.insert(i); cin >> x[i] >> y[i] >> r[i]; } iota(all(id), 1); sort(all(id), [&](const int &i, const int &j) { if (r[i] != r[j]) return r[i] > r[j]; return i < j; }); for (int &i : id) { if (ans[i]) continue; if (r[i] * 2 <= blockSize) { blockSize = r[i]; rebuild(); } for (int x = ::x[i] / blockSize - 2; x <= ::x[i] / blockSize + 2; x++) { for (int y = ::y[i] / blockSize - 2; y <= ::y[i] / blockSize + 2; y++) { if (!block.count({x, y})) continue; for (int &j : block[{x, y}]) if (!ans[j]) { if (dist(i, j) <= sq(r[i] + r[j])) { ans[j] = i; S.erase(j); } } } } } for (int i = 1; i <= n; i++) cout << ans[i] << ' '; } int32_t main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); #define TASK "" if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout); } if (fopen("TASK.INP", "r")) { freopen("TASK.INP", "r", stdin); freopen("TASK.OUT", "w", stdout); } /* int TEST = 1; cin >> TEST; while (TEST--) */ Solve(); cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 604 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 352 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 552 KB | Output is correct |
17 | Correct | 2 ms | 604 KB | Output is correct |
18 | Correct | 2 ms | 604 KB | Output is correct |
19 | Correct | 4 ms | 860 KB | Output is correct |
20 | Correct | 4 ms | 904 KB | Output is correct |
21 | Correct | 5 ms | 908 KB | Output is correct |
22 | Correct | 14 ms | 1372 KB | Output is correct |
23 | Correct | 14 ms | 1552 KB | Output is correct |
24 | Correct | 13 ms | 1412 KB | Output is correct |
25 | Correct | 11 ms | 1372 KB | Output is correct |
26 | Correct | 13 ms | 1372 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 191 ms | 22620 KB | Output is correct |
2 | Correct | 208 ms | 29864 KB | Output is correct |
3 | Correct | 228 ms | 30056 KB | Output is correct |
4 | Correct | 218 ms | 29240 KB | Output is correct |
5 | Correct | 365 ms | 29524 KB | Output is correct |
6 | Correct | 807 ms | 43080 KB | Output is correct |
7 | Correct | 443 ms | 31136 KB | Output is correct |
8 | Correct | 513 ms | 33352 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 465 ms | 21292 KB | Output is correct |
3 | Correct | 1931 ms | 63196 KB | Output is correct |
4 | Correct | 2053 ms | 63304 KB | Output is correct |
5 | Correct | 1765 ms | 56392 KB | Output is correct |
6 | Correct | 581 ms | 28592 KB | Output is correct |
7 | Correct | 231 ms | 15432 KB | Output is correct |
8 | Correct | 36 ms | 3664 KB | Output is correct |
9 | Correct | 2188 ms | 62364 KB | Output is correct |
10 | Correct | 1491 ms | 55528 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1424 ms | 55112 KB | Output is correct |
2 | Correct | 1034 ms | 62292 KB | Output is correct |
3 | Correct | 606 ms | 40536 KB | Output is correct |
4 | Correct | 1033 ms | 62592 KB | Output is correct |
5 | Correct | 1038 ms | 62664 KB | Output is correct |
6 | Correct | 467 ms | 34132 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 604 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 352 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 552 KB | Output is correct |
17 | Correct | 2 ms | 604 KB | Output is correct |
18 | Correct | 2 ms | 604 KB | Output is correct |
19 | Correct | 4 ms | 860 KB | Output is correct |
20 | Correct | 4 ms | 904 KB | Output is correct |
21 | Correct | 5 ms | 908 KB | Output is correct |
22 | Correct | 14 ms | 1372 KB | Output is correct |
23 | Correct | 14 ms | 1552 KB | Output is correct |
24 | Correct | 13 ms | 1412 KB | Output is correct |
25 | Correct | 11 ms | 1372 KB | Output is correct |
26 | Correct | 13 ms | 1372 KB | Output is correct |
27 | Correct | 7 ms | 1372 KB | Output is correct |
28 | Correct | 7 ms | 1536 KB | Output is correct |
29 | Correct | 7 ms | 1528 KB | Output is correct |
30 | Correct | 27 ms | 2468 KB | Output is correct |
31 | Correct | 27 ms | 2412 KB | Output is correct |
32 | Correct | 25 ms | 2396 KB | Output is correct |
33 | Correct | 73 ms | 11352 KB | Output is correct |
34 | Correct | 66 ms | 11372 KB | Output is correct |
35 | Correct | 81 ms | 10740 KB | Output is correct |
36 | Correct | 385 ms | 21004 KB | Output is correct |
37 | Correct | 407 ms | 21144 KB | Output is correct |
38 | Correct | 432 ms | 21120 KB | Output is correct |
39 | Correct | 328 ms | 18064 KB | Output is correct |
40 | Correct | 316 ms | 18136 KB | Output is correct |
41 | Correct | 307 ms | 18124 KB | Output is correct |
42 | Correct | 260 ms | 20056 KB | Output is correct |
43 | Correct | 271 ms | 21072 KB | Output is correct |
44 | Correct | 258 ms | 20820 KB | Output is correct |
45 | Correct | 270 ms | 20988 KB | Output is correct |
46 | Correct | 313 ms | 21028 KB | Output is correct |
47 | Correct | 267 ms | 20964 KB | Output is correct |
48 | Correct | 279 ms | 20816 KB | Output is correct |
49 | Correct | 270 ms | 20916 KB | Output is correct |
50 | Correct | 262 ms | 20944 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 604 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 352 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 552 KB | Output is correct |
17 | Correct | 2 ms | 604 KB | Output is correct |
18 | Correct | 2 ms | 604 KB | Output is correct |
19 | Correct | 4 ms | 860 KB | Output is correct |
20 | Correct | 4 ms | 904 KB | Output is correct |
21 | Correct | 5 ms | 908 KB | Output is correct |
22 | Correct | 14 ms | 1372 KB | Output is correct |
23 | Correct | 14 ms | 1552 KB | Output is correct |
24 | Correct | 13 ms | 1412 KB | Output is correct |
25 | Correct | 11 ms | 1372 KB | Output is correct |
26 | Correct | 13 ms | 1372 KB | Output is correct |
27 | Correct | 191 ms | 22620 KB | Output is correct |
28 | Correct | 208 ms | 29864 KB | Output is correct |
29 | Correct | 228 ms | 30056 KB | Output is correct |
30 | Correct | 218 ms | 29240 KB | Output is correct |
31 | Correct | 365 ms | 29524 KB | Output is correct |
32 | Correct | 807 ms | 43080 KB | Output is correct |
33 | Correct | 443 ms | 31136 KB | Output is correct |
34 | Correct | 513 ms | 33352 KB | Output is correct |
35 | Correct | 1 ms | 336 KB | Output is correct |
36 | Correct | 465 ms | 21292 KB | Output is correct |
37 | Correct | 1931 ms | 63196 KB | Output is correct |
38 | Correct | 2053 ms | 63304 KB | Output is correct |
39 | Correct | 1765 ms | 56392 KB | Output is correct |
40 | Correct | 581 ms | 28592 KB | Output is correct |
41 | Correct | 231 ms | 15432 KB | Output is correct |
42 | Correct | 36 ms | 3664 KB | Output is correct |
43 | Correct | 2188 ms | 62364 KB | Output is correct |
44 | Correct | 1491 ms | 55528 KB | Output is correct |
45 | Correct | 1424 ms | 55112 KB | Output is correct |
46 | Correct | 1034 ms | 62292 KB | Output is correct |
47 | Correct | 606 ms | 40536 KB | Output is correct |
48 | Correct | 1033 ms | 62592 KB | Output is correct |
49 | Correct | 1038 ms | 62664 KB | Output is correct |
50 | Correct | 467 ms | 34132 KB | Output is correct |
51 | Correct | 7 ms | 1372 KB | Output is correct |
52 | Correct | 7 ms | 1536 KB | Output is correct |
53 | Correct | 7 ms | 1528 KB | Output is correct |
54 | Correct | 27 ms | 2468 KB | Output is correct |
55 | Correct | 27 ms | 2412 KB | Output is correct |
56 | Correct | 25 ms | 2396 KB | Output is correct |
57 | Correct | 73 ms | 11352 KB | Output is correct |
58 | Correct | 66 ms | 11372 KB | Output is correct |
59 | Correct | 81 ms | 10740 KB | Output is correct |
60 | Correct | 385 ms | 21004 KB | Output is correct |
61 | Correct | 407 ms | 21144 KB | Output is correct |
62 | Correct | 432 ms | 21120 KB | Output is correct |
63 | Correct | 328 ms | 18064 KB | Output is correct |
64 | Correct | 316 ms | 18136 KB | Output is correct |
65 | Correct | 307 ms | 18124 KB | Output is correct |
66 | Correct | 260 ms | 20056 KB | Output is correct |
67 | Correct | 271 ms | 21072 KB | Output is correct |
68 | Correct | 258 ms | 20820 KB | Output is correct |
69 | Correct | 270 ms | 20988 KB | Output is correct |
70 | Correct | 313 ms | 21028 KB | Output is correct |
71 | Correct | 267 ms | 20964 KB | Output is correct |
72 | Correct | 279 ms | 20816 KB | Output is correct |
73 | Correct | 270 ms | 20916 KB | Output is correct |
74 | Correct | 262 ms | 20944 KB | Output is correct |
75 | Correct | 247 ms | 32176 KB | Output is correct |
76 | Correct | 262 ms | 31484 KB | Output is correct |
77 | Correct | 207 ms | 32616 KB | Output is correct |
78 | Correct | 203 ms | 32460 KB | Output is correct |
79 | Correct | 324 ms | 31408 KB | Output is correct |
80 | Correct | 217 ms | 32324 KB | Output is correct |
81 | Correct | 1938 ms | 63316 KB | Output is correct |
82 | Correct | 1807 ms | 63048 KB | Output is correct |
83 | Correct | 1789 ms | 63060 KB | Output is correct |
84 | Correct | 2007 ms | 63572 KB | Output is correct |
85 | Correct | 1867 ms | 62992 KB | Output is correct |
86 | Correct | 1815 ms | 63036 KB | Output is correct |
87 | Correct | 1958 ms | 62960 KB | Output is correct |
88 | Correct | 1438 ms | 53736 KB | Output is correct |
89 | Correct | 1508 ms | 53628 KB | Output is correct |
90 | Correct | 1497 ms | 53532 KB | Output is correct |
91 | Correct | 1421 ms | 53676 KB | Output is correct |
92 | Correct | 1441 ms | 53592 KB | Output is correct |
93 | Correct | 1308 ms | 61944 KB | Output is correct |
94 | Correct | 1355 ms | 62188 KB | Output is correct |
95 | Correct | 1295 ms | 62032 KB | Output is correct |
96 | Correct | 1370 ms | 62096 KB | Output is correct |
97 | Correct | 1950 ms | 61940 KB | Output is correct |
98 | Correct | 998 ms | 50260 KB | Output is correct |
99 | Correct | 1503 ms | 62348 KB | Output is correct |
100 | Correct | 1301 ms | 61952 KB | Output is correct |
101 | Correct | 1351 ms | 55384 KB | Output is correct |
102 | Correct | 1389 ms | 61772 KB | Output is correct |
103 | Correct | 1799 ms | 61796 KB | Output is correct |
104 | Correct | 1346 ms | 61984 KB | Output is correct |
105 | Correct | 1190 ms | 59720 KB | Output is correct |
106 | Correct | 1071 ms | 60796 KB | Output is correct |
107 | Correct | 1128 ms | 60756 KB | Output is correct |
108 | Correct | 1049 ms | 60712 KB | Output is correct |
109 | Correct | 1052 ms | 60776 KB | Output is correct |
110 | Correct | 1069 ms | 60676 KB | Output is correct |
111 | Correct | 1079 ms | 60736 KB | Output is correct |
112 | Correct | 953 ms | 60756 KB | Output is correct |
113 | Correct | 1038 ms | 60868 KB | Output is correct |
114 | Correct | 1032 ms | 60808 KB | Output is correct |
115 | Correct | 1105 ms | 60756 KB | Output is correct |
116 | Correct | 1014 ms | 60612 KB | Output is correct |