답안 #985057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985057 2024-05-17T10:08:01 Z Tsagana 원 고르기 (APIO18_circle_selection) C++14
100 / 100
1907 ms 55172 KB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pi pair<int, int >
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define mset multiset
#define F first
#define S second

using namespace std;

struct circle {
	int x, y, r;
	void init() {cin >> x >> y >> r;}
};
circle C[300001];
int n, mx, ans[300001];
map<pair<int, int>, vector<int>> mp;
 
bool check(int i, int j) {
	int d = (C[i].x - C[j].x) * (C[i].x - C[j].x);
	d += (C[i].y - C[j].y) * (C[i].y - C[j].y);
	return (d <= (C[i].r + C[j].r) * (C[i].r + C[j].r));
}
void build() {mp.clear();
	for (int i = 1; i <= n; i++) if (!ans[i]) mp[{C[i].x/mx, C[i].y/mx}].pb(i);
}
bool cmp(int a, int b) {return (C[a].r >  C[b].r || (C[a].r == C[b].r && a < b));}
void solve() {
	cin >> n; for (int i = 1; i <= n; i++)
	{C[i].init(); C[i].x += 1e9; C[i].y += 1e9; mx = max(mx, C[i].r);}
	vector<int> v(n); iota(all(v), 1); sort(all(v), cmp); build();
	for (int i: v) {
		if  (ans[i]) continue;
		if  (C[i].r <= mx / 2) {mx /= 2; build();}
		for (int j = C[i].x/mx-2; j <= C[i].x/mx+2; j++)
		for (int k = C[i].y/mx-2; k <= C[i].y/mx+2; k++) {
			if (!mp.count({j, k})) continue;
			for (int l: mp[{j, k}]) if (!ans[l] && check(i, l)) ans[l] = i;
		}
	}
	for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
}
signed main() {IOS solve(); return 0;}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 2 ms 2528 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 4 ms 2668 KB Output is correct
20 Correct 3 ms 2652 KB Output is correct
21 Correct 3 ms 2652 KB Output is correct
22 Correct 12 ms 3300 KB Output is correct
23 Correct 14 ms 3164 KB Output is correct
24 Correct 12 ms 3164 KB Output is correct
25 Correct 11 ms 3268 KB Output is correct
26 Correct 11 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 21280 KB Output is correct
2 Correct 130 ms 21264 KB Output is correct
3 Correct 135 ms 23080 KB Output is correct
4 Correct 137 ms 22092 KB Output is correct
5 Correct 175 ms 23084 KB Output is correct
6 Correct 643 ms 35604 KB Output is correct
7 Correct 226 ms 25116 KB Output is correct
8 Correct 276 ms 26904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 374 ms 20364 KB Output is correct
3 Correct 1591 ms 54948 KB Output is correct
4 Correct 1555 ms 54932 KB Output is correct
5 Correct 1467 ms 48756 KB Output is correct
6 Correct 460 ms 24672 KB Output is correct
7 Correct 173 ms 15432 KB Output is correct
8 Correct 26 ms 4768 KB Output is correct
9 Correct 1671 ms 54200 KB Output is correct
10 Correct 1253 ms 47660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1308 ms 54840 KB Output is correct
2 Correct 880 ms 54244 KB Output is correct
3 Correct 357 ms 34024 KB Output is correct
4 Correct 898 ms 54356 KB Output is correct
5 Correct 877 ms 54584 KB Output is correct
6 Correct 182 ms 27976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 2 ms 2528 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 4 ms 2668 KB Output is correct
20 Correct 3 ms 2652 KB Output is correct
21 Correct 3 ms 2652 KB Output is correct
22 Correct 12 ms 3300 KB Output is correct
23 Correct 14 ms 3164 KB Output is correct
24 Correct 12 ms 3164 KB Output is correct
25 Correct 11 ms 3268 KB Output is correct
26 Correct 11 ms 3164 KB Output is correct
27 Correct 7 ms 2908 KB Output is correct
28 Correct 5 ms 3164 KB Output is correct
29 Correct 5 ms 3132 KB Output is correct
30 Correct 30 ms 4028 KB Output is correct
31 Correct 24 ms 3932 KB Output is correct
32 Correct 24 ms 3928 KB Output is correct
33 Correct 44 ms 10716 KB Output is correct
34 Correct 45 ms 10924 KB Output is correct
35 Correct 51 ms 10356 KB Output is correct
36 Correct 305 ms 20304 KB Output is correct
37 Correct 305 ms 20308 KB Output is correct
38 Correct 306 ms 20304 KB Output is correct
39 Correct 340 ms 17192 KB Output is correct
40 Correct 326 ms 17296 KB Output is correct
41 Correct 325 ms 17152 KB Output is correct
42 Correct 173 ms 19192 KB Output is correct
43 Correct 267 ms 19968 KB Output is correct
44 Correct 227 ms 19968 KB Output is correct
45 Correct 222 ms 19948 KB Output is correct
46 Correct 216 ms 19920 KB Output is correct
47 Correct 216 ms 19796 KB Output is correct
48 Correct 239 ms 19796 KB Output is correct
49 Correct 219 ms 19952 KB Output is correct
50 Correct 242 ms 19796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 2 ms 2528 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 4 ms 2668 KB Output is correct
20 Correct 3 ms 2652 KB Output is correct
21 Correct 3 ms 2652 KB Output is correct
22 Correct 12 ms 3300 KB Output is correct
23 Correct 14 ms 3164 KB Output is correct
24 Correct 12 ms 3164 KB Output is correct
25 Correct 11 ms 3268 KB Output is correct
26 Correct 11 ms 3164 KB Output is correct
27 Correct 157 ms 21280 KB Output is correct
28 Correct 130 ms 21264 KB Output is correct
29 Correct 135 ms 23080 KB Output is correct
30 Correct 137 ms 22092 KB Output is correct
31 Correct 175 ms 23084 KB Output is correct
32 Correct 643 ms 35604 KB Output is correct
33 Correct 226 ms 25116 KB Output is correct
34 Correct 276 ms 26904 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 374 ms 20364 KB Output is correct
37 Correct 1591 ms 54948 KB Output is correct
38 Correct 1555 ms 54932 KB Output is correct
39 Correct 1467 ms 48756 KB Output is correct
40 Correct 460 ms 24672 KB Output is correct
41 Correct 173 ms 15432 KB Output is correct
42 Correct 26 ms 4768 KB Output is correct
43 Correct 1671 ms 54200 KB Output is correct
44 Correct 1253 ms 47660 KB Output is correct
45 Correct 1308 ms 54840 KB Output is correct
46 Correct 880 ms 54244 KB Output is correct
47 Correct 357 ms 34024 KB Output is correct
48 Correct 898 ms 54356 KB Output is correct
49 Correct 877 ms 54584 KB Output is correct
50 Correct 182 ms 27976 KB Output is correct
51 Correct 7 ms 2908 KB Output is correct
52 Correct 5 ms 3164 KB Output is correct
53 Correct 5 ms 3132 KB Output is correct
54 Correct 30 ms 4028 KB Output is correct
55 Correct 24 ms 3932 KB Output is correct
56 Correct 24 ms 3928 KB Output is correct
57 Correct 44 ms 10716 KB Output is correct
58 Correct 45 ms 10924 KB Output is correct
59 Correct 51 ms 10356 KB Output is correct
60 Correct 305 ms 20304 KB Output is correct
61 Correct 305 ms 20308 KB Output is correct
62 Correct 306 ms 20304 KB Output is correct
63 Correct 340 ms 17192 KB Output is correct
64 Correct 326 ms 17296 KB Output is correct
65 Correct 325 ms 17152 KB Output is correct
66 Correct 173 ms 19192 KB Output is correct
67 Correct 267 ms 19968 KB Output is correct
68 Correct 227 ms 19968 KB Output is correct
69 Correct 222 ms 19948 KB Output is correct
70 Correct 216 ms 19920 KB Output is correct
71 Correct 216 ms 19796 KB Output is correct
72 Correct 239 ms 19796 KB Output is correct
73 Correct 219 ms 19952 KB Output is correct
74 Correct 242 ms 19796 KB Output is correct
75 Correct 167 ms 24448 KB Output is correct
76 Correct 150 ms 23380 KB Output is correct
77 Correct 138 ms 25520 KB Output is correct
78 Correct 150 ms 25480 KB Output is correct
79 Correct 180 ms 24540 KB Output is correct
80 Correct 151 ms 25300 KB Output is correct
81 Correct 1602 ms 54992 KB Output is correct
82 Correct 1473 ms 54732 KB Output is correct
83 Correct 1434 ms 54668 KB Output is correct
84 Correct 1637 ms 55172 KB Output is correct
85 Correct 1514 ms 54740 KB Output is correct
86 Correct 1389 ms 54824 KB Output is correct
87 Correct 1732 ms 54768 KB Output is correct
88 Correct 1602 ms 45876 KB Output is correct
89 Correct 1469 ms 46024 KB Output is correct
90 Correct 1520 ms 45696 KB Output is correct
91 Correct 1578 ms 45864 KB Output is correct
92 Correct 1456 ms 45836 KB Output is correct
93 Correct 1140 ms 53756 KB Output is correct
94 Correct 1483 ms 54060 KB Output is correct
95 Correct 1261 ms 53744 KB Output is correct
96 Correct 1307 ms 53760 KB Output is correct
97 Correct 1907 ms 53688 KB Output is correct
98 Correct 827 ms 42428 KB Output is correct
99 Correct 1190 ms 53920 KB Output is correct
100 Correct 1137 ms 53688 KB Output is correct
101 Correct 1087 ms 47372 KB Output is correct
102 Correct 1148 ms 53344 KB Output is correct
103 Correct 1657 ms 53364 KB Output is correct
104 Correct 1172 ms 53888 KB Output is correct
105 Correct 898 ms 51448 KB Output is correct
106 Correct 810 ms 52564 KB Output is correct
107 Correct 819 ms 52532 KB Output is correct
108 Correct 796 ms 52624 KB Output is correct
109 Correct 823 ms 52472 KB Output is correct
110 Correct 801 ms 52656 KB Output is correct
111 Correct 861 ms 52460 KB Output is correct
112 Correct 793 ms 52660 KB Output is correct
113 Correct 822 ms 52604 KB Output is correct
114 Correct 810 ms 52560 KB Output is correct
115 Correct 809 ms 52540 KB Output is correct
116 Correct 784 ms 52436 KB Output is correct