답안 #728315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
728315 2023-04-22T07:23:29 Z SanguineChameleon 원 고르기 (APIO18_circle_selection) C++17
87 / 100
3000 ms 63964 KB
#include <bits/stdc++.h>
using namespace std;

void just_do_it();

int main() {
	#ifdef KAMIRULEZ
		freopen("kamirulez.inp", "r", stdin);
		freopen("kamirulez.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	just_do_it();
	return 0;
}

struct circle {
	int x, y, r;
};

bool intersect(circle C1, circle C2) {
	return 1LL * (C1.r + C2.r) * (C1.r + C2.r) >= 1LL * (C1.x - C2.x) * (C1.x - C2.x) + 1LL * (C1.y - C2.y) * (C1.y - C2.y); 
}

const int maxn = 3e5 + 20;
circle C[maxn];
int res[maxn];
set<pair<int, int>> S;
map<int, set<pair<int, int>>> groups;
int n;

int floor(int a, int b) {
	return (a / b) - (a % b && (a ^ b) < 0);
}

void build(int len) {
	groups.clear();
	for (auto p: S) {
		int i = p.second;
		int cx = floor(C[i].x, len);
		int cy = floor(C[i].y, len);
		groups[cx].insert({cy, i});
	}
}

void just_do_it() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> C[i].x >> C[i].y >> C[i].r;
		S.insert({-C[i].r, i});
	}
	int len = -1;
	while (!S.empty()) {
		int cur = S.begin()->second;
		if (len == -1 || C[cur].r * 2 < len) {
			len = C[cur].r;
			build(len);
		}
		int cx = floor(C[cur].x, len);
		int cy = floor(C[cur].y, len);
		for (int i = -2; i <= 2; i++) {
			auto g_it = groups.find({cx + i});
			if (g_it == groups.end()) {
				continue;
			}
			auto it = g_it->second.lower_bound({cy - 2, -1});
			while (it != g_it->second.end()) {
				if (it->first > cy + 2) {
					break;
				}
				int can = it->second;
				if (intersect(C[cur], C[can])) {
					res[can] = cur;
					it = g_it->second.erase(it);
					S.erase({-C[can].r, can});
				}
				else {
					it++;
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << res[i] << " ";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 380 KB Output is correct
19 Correct 6 ms 968 KB Output is correct
20 Correct 5 ms 1044 KB Output is correct
21 Correct 5 ms 980 KB Output is correct
22 Correct 9 ms 1236 KB Output is correct
23 Correct 10 ms 1040 KB Output is correct
24 Correct 9 ms 1336 KB Output is correct
25 Correct 9 ms 1472 KB Output is correct
26 Correct 10 ms 1360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 644 ms 35560 KB Output is correct
2 Correct 760 ms 35652 KB Output is correct
3 Correct 711 ms 35352 KB Output is correct
4 Correct 606 ms 35624 KB Output is correct
5 Correct 628 ms 36092 KB Output is correct
6 Correct 909 ms 49316 KB Output is correct
7 Correct 715 ms 37148 KB Output is correct
8 Correct 804 ms 39496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 382 ms 12716 KB Output is correct
3 Correct 1449 ms 37420 KB Output is correct
4 Correct 1477 ms 37428 KB Output is correct
5 Correct 1408 ms 34924 KB Output is correct
6 Correct 546 ms 19088 KB Output is correct
7 Correct 199 ms 10552 KB Output is correct
8 Correct 27 ms 3148 KB Output is correct
9 Correct 1568 ms 36404 KB Output is correct
10 Correct 1482 ms 36068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 898 ms 43556 KB Output is correct
2 Correct 844 ms 63964 KB Output is correct
3 Correct 690 ms 35648 KB Output is correct
4 Correct 907 ms 62052 KB Output is correct
5 Correct 892 ms 63264 KB Output is correct
6 Correct 601 ms 35388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 380 KB Output is correct
19 Correct 6 ms 968 KB Output is correct
20 Correct 5 ms 1044 KB Output is correct
21 Correct 5 ms 980 KB Output is correct
22 Correct 9 ms 1236 KB Output is correct
23 Correct 10 ms 1040 KB Output is correct
24 Correct 9 ms 1336 KB Output is correct
25 Correct 9 ms 1472 KB Output is correct
26 Correct 10 ms 1360 KB Output is correct
27 Correct 12 ms 1620 KB Output is correct
28 Correct 11 ms 1620 KB Output is correct
29 Correct 12 ms 1616 KB Output is correct
30 Correct 18 ms 1944 KB Output is correct
31 Correct 18 ms 2252 KB Output is correct
32 Correct 18 ms 2248 KB Output is correct
33 Correct 149 ms 12092 KB Output is correct
34 Correct 175 ms 12108 KB Output is correct
35 Correct 189 ms 12108 KB Output is correct
36 Correct 351 ms 15724 KB Output is correct
37 Correct 395 ms 15692 KB Output is correct
38 Correct 354 ms 14288 KB Output is correct
39 Correct 851 ms 12052 KB Output is correct
40 Correct 803 ms 12208 KB Output is correct
41 Correct 805 ms 12104 KB Output is correct
42 Correct 161 ms 12036 KB Output is correct
43 Correct 202 ms 21208 KB Output is correct
44 Correct 213 ms 21252 KB Output is correct
45 Correct 258 ms 21112 KB Output is correct
46 Correct 217 ms 21224 KB Output is correct
47 Correct 225 ms 21132 KB Output is correct
48 Correct 224 ms 21196 KB Output is correct
49 Correct 222 ms 21264 KB Output is correct
50 Correct 222 ms 21228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 380 KB Output is correct
19 Correct 6 ms 968 KB Output is correct
20 Correct 5 ms 1044 KB Output is correct
21 Correct 5 ms 980 KB Output is correct
22 Correct 9 ms 1236 KB Output is correct
23 Correct 10 ms 1040 KB Output is correct
24 Correct 9 ms 1336 KB Output is correct
25 Correct 9 ms 1472 KB Output is correct
26 Correct 10 ms 1360 KB Output is correct
27 Correct 644 ms 35560 KB Output is correct
28 Correct 760 ms 35652 KB Output is correct
29 Correct 711 ms 35352 KB Output is correct
30 Correct 606 ms 35624 KB Output is correct
31 Correct 628 ms 36092 KB Output is correct
32 Correct 909 ms 49316 KB Output is correct
33 Correct 715 ms 37148 KB Output is correct
34 Correct 804 ms 39496 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 382 ms 12716 KB Output is correct
37 Correct 1449 ms 37420 KB Output is correct
38 Correct 1477 ms 37428 KB Output is correct
39 Correct 1408 ms 34924 KB Output is correct
40 Correct 546 ms 19088 KB Output is correct
41 Correct 199 ms 10552 KB Output is correct
42 Correct 27 ms 3148 KB Output is correct
43 Correct 1568 ms 36404 KB Output is correct
44 Correct 1482 ms 36068 KB Output is correct
45 Correct 898 ms 43556 KB Output is correct
46 Correct 844 ms 63964 KB Output is correct
47 Correct 690 ms 35648 KB Output is correct
48 Correct 907 ms 62052 KB Output is correct
49 Correct 892 ms 63264 KB Output is correct
50 Correct 601 ms 35388 KB Output is correct
51 Correct 12 ms 1620 KB Output is correct
52 Correct 11 ms 1620 KB Output is correct
53 Correct 12 ms 1616 KB Output is correct
54 Correct 18 ms 1944 KB Output is correct
55 Correct 18 ms 2252 KB Output is correct
56 Correct 18 ms 2248 KB Output is correct
57 Correct 149 ms 12092 KB Output is correct
58 Correct 175 ms 12108 KB Output is correct
59 Correct 189 ms 12108 KB Output is correct
60 Correct 351 ms 15724 KB Output is correct
61 Correct 395 ms 15692 KB Output is correct
62 Correct 354 ms 14288 KB Output is correct
63 Correct 851 ms 12052 KB Output is correct
64 Correct 803 ms 12208 KB Output is correct
65 Correct 805 ms 12104 KB Output is correct
66 Correct 161 ms 12036 KB Output is correct
67 Correct 202 ms 21208 KB Output is correct
68 Correct 213 ms 21252 KB Output is correct
69 Correct 258 ms 21112 KB Output is correct
70 Correct 217 ms 21224 KB Output is correct
71 Correct 225 ms 21132 KB Output is correct
72 Correct 224 ms 21196 KB Output is correct
73 Correct 222 ms 21264 KB Output is correct
74 Correct 222 ms 21228 KB Output is correct
75 Correct 749 ms 35676 KB Output is correct
76 Correct 746 ms 35640 KB Output is correct
77 Correct 646 ms 35772 KB Output is correct
78 Correct 679 ms 35312 KB Output is correct
79 Correct 786 ms 35484 KB Output is correct
80 Correct 609 ms 35540 KB Output is correct
81 Correct 1332 ms 38132 KB Output is correct
82 Correct 1366 ms 40024 KB Output is correct
83 Correct 1477 ms 40044 KB Output is correct
84 Correct 1393 ms 36604 KB Output is correct
85 Correct 1393 ms 38612 KB Output is correct
86 Correct 1313 ms 40652 KB Output is correct
87 Correct 1292 ms 35816 KB Output is correct
88 Execution timed out 3081 ms 32188 KB Time limit exceeded
89 Halted 0 ms 0 KB -