#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef unsigned long long ull;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
const int inf = 1e9, maxn = 2e5 + 48, mod = 998244353, N = 3e5 + 12;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;
struct point {
int x, y, r, id;
bool operator < (const point &a) const {
if (r != a.r)
return r > a.r;
return id < a.id;
}
} a[N];
int n, res[N], bl;
vpii vals;
pii b[N];
vi m[N];
inline int getId (pii x) {
return lower_bound(all(vals), x) - vals.begin();
}
inline bool check (int i, int j) {
return (a[i].x - a[j].x) * 1ll * (a[i].x - a[j].x) + (a[i].y - a[j].y) * 1ll * (a[i].y - a[j].y) <= (a[i].r + a[j].r) * 1ll * (a[i].r + a[j].r);
}
inline void build () {
vals.clear();
for (int i = 1; i <= n; ++i)
if (!res[a[i].id]) {
b[i] = mp(a[i].x / bl, a[i].y / bl);
vals.pb(b[i]);
}
sort(all(vals));
vals.resize(unique(all(vals)) - vals.begin());
for (int i = 0; i < sz(vals); ++i)
m[i].clear();
for (int i = 1; i <= n; ++i)
if (!res[a[i].id])
m[getId(b[i])].pb(i);
}
main () {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].r);
a[i].id = i;
}
sort(a + 1, a + 1 + n);
bl = a[1].r;
build();
for (int i = 1; i <= n; ++i)
if (!res[a[i].id]) {
if (a[i].r + a[i].r <= bl) {
bl = a[i].r;
build();
}
vector < point > V;
point Mn;
Mn.r = -inf;
for (int c = -2; c <= 2; ++c)
for (int d = -2; d <= 2; ++d) {
pii cur = mp(b[i].f + c, b[i].s + d);
int z = getId(cur);
if (z == sz(vals) || vals[z] != cur)
continue;
for (auto j : m[z])
if (!res[a[j].id] && check(i, j)) {
if (a[j] < Mn)
Mn = a[j];
V.pb(a[j]);
}
}
if (Mn < a[i]) {
res[a[i].id] = Mn.id;
continue;
}
res[a[i].id] = a[i].id;
for (auto j : V)
res[j.id] = a[i].id;
}
for (int i = 1; i <= n; ++i)
printf("%d ", res[i]);
}
Compilation message
circle_selection.cpp:87:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
87 | main () {
| ^
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:88:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
88 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
circle_selection.cpp:90:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
90 | scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].r);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
circle_selection.cpp:50:17: warning: 'Mn.point::id' may be used uninitialized in this function [-Wmaybe-uninitialized]
50 | return id < a.id;
| ^~
circle_selection.cpp:107:10: note: 'Mn.point::id' was declared here
107 | point Mn;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
6 ms |
7424 KB |
Output is correct |
4 |
Correct |
5 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
5 ms |
7424 KB |
Output is correct |
7 |
Correct |
6 ms |
7424 KB |
Output is correct |
8 |
Correct |
5 ms |
7424 KB |
Output is correct |
9 |
Correct |
5 ms |
7424 KB |
Output is correct |
10 |
Correct |
5 ms |
7424 KB |
Output is correct |
11 |
Correct |
5 ms |
7424 KB |
Output is correct |
12 |
Correct |
6 ms |
7424 KB |
Output is correct |
13 |
Correct |
5 ms |
7424 KB |
Output is correct |
14 |
Correct |
5 ms |
7424 KB |
Output is correct |
15 |
Correct |
5 ms |
7424 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
5 ms |
7424 KB |
Output is correct |
18 |
Correct |
6 ms |
7424 KB |
Output is correct |
19 |
Correct |
9 ms |
7884 KB |
Output is correct |
20 |
Correct |
9 ms |
7808 KB |
Output is correct |
21 |
Correct |
9 ms |
7808 KB |
Output is correct |
22 |
Correct |
18 ms |
7936 KB |
Output is correct |
23 |
Correct |
19 ms |
7680 KB |
Output is correct |
24 |
Correct |
18 ms |
7680 KB |
Output is correct |
25 |
Correct |
17 ms |
7680 KB |
Output is correct |
26 |
Correct |
17 ms |
7680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
259 ms |
30308 KB |
Output is correct |
2 |
Correct |
249 ms |
28172 KB |
Output is correct |
3 |
Correct |
235 ms |
27616 KB |
Output is correct |
4 |
Correct |
237 ms |
31324 KB |
Output is correct |
5 |
Correct |
293 ms |
21864 KB |
Output is correct |
6 |
Correct |
642 ms |
24796 KB |
Output is correct |
7 |
Correct |
339 ms |
22368 KB |
Output is correct |
8 |
Correct |
391 ms |
22620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
353 ms |
14712 KB |
Output is correct |
3 |
Correct |
1213 ms |
29564 KB |
Output is correct |
4 |
Correct |
1228 ms |
29364 KB |
Output is correct |
5 |
Correct |
1164 ms |
27396 KB |
Output is correct |
6 |
Correct |
469 ms |
17508 KB |
Output is correct |
7 |
Correct |
219 ms |
12776 KB |
Output is correct |
8 |
Correct |
44 ms |
8564 KB |
Output is correct |
9 |
Correct |
1376 ms |
29148 KB |
Output is correct |
10 |
Correct |
1053 ms |
27136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1075 ms |
29356 KB |
Output is correct |
2 |
Correct |
901 ms |
29392 KB |
Output is correct |
3 |
Correct |
446 ms |
22880 KB |
Output is correct |
4 |
Correct |
922 ms |
29532 KB |
Output is correct |
5 |
Correct |
924 ms |
29404 KB |
Output is correct |
6 |
Correct |
338 ms |
21676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
6 ms |
7424 KB |
Output is correct |
4 |
Correct |
5 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
5 ms |
7424 KB |
Output is correct |
7 |
Correct |
6 ms |
7424 KB |
Output is correct |
8 |
Correct |
5 ms |
7424 KB |
Output is correct |
9 |
Correct |
5 ms |
7424 KB |
Output is correct |
10 |
Correct |
5 ms |
7424 KB |
Output is correct |
11 |
Correct |
5 ms |
7424 KB |
Output is correct |
12 |
Correct |
6 ms |
7424 KB |
Output is correct |
13 |
Correct |
5 ms |
7424 KB |
Output is correct |
14 |
Correct |
5 ms |
7424 KB |
Output is correct |
15 |
Correct |
5 ms |
7424 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
5 ms |
7424 KB |
Output is correct |
18 |
Correct |
6 ms |
7424 KB |
Output is correct |
19 |
Correct |
9 ms |
7884 KB |
Output is correct |
20 |
Correct |
9 ms |
7808 KB |
Output is correct |
21 |
Correct |
9 ms |
7808 KB |
Output is correct |
22 |
Correct |
18 ms |
7936 KB |
Output is correct |
23 |
Correct |
19 ms |
7680 KB |
Output is correct |
24 |
Correct |
18 ms |
7680 KB |
Output is correct |
25 |
Correct |
17 ms |
7680 KB |
Output is correct |
26 |
Correct |
17 ms |
7680 KB |
Output is correct |
27 |
Correct |
13 ms |
8192 KB |
Output is correct |
28 |
Correct |
13 ms |
8192 KB |
Output is correct |
29 |
Correct |
15 ms |
8192 KB |
Output is correct |
30 |
Correct |
35 ms |
8064 KB |
Output is correct |
31 |
Correct |
32 ms |
8064 KB |
Output is correct |
32 |
Correct |
32 ms |
8096 KB |
Output is correct |
33 |
Correct |
96 ms |
14060 KB |
Output is correct |
34 |
Correct |
97 ms |
14188 KB |
Output is correct |
35 |
Correct |
99 ms |
14188 KB |
Output is correct |
36 |
Correct |
335 ms |
14700 KB |
Output is correct |
37 |
Correct |
337 ms |
14572 KB |
Output is correct |
38 |
Correct |
346 ms |
14696 KB |
Output is correct |
39 |
Correct |
373 ms |
15468 KB |
Output is correct |
40 |
Correct |
353 ms |
15360 KB |
Output is correct |
41 |
Correct |
337 ms |
15340 KB |
Output is correct |
42 |
Correct |
232 ms |
14568 KB |
Output is correct |
43 |
Correct |
286 ms |
14536 KB |
Output is correct |
44 |
Correct |
288 ms |
14568 KB |
Output is correct |
45 |
Correct |
263 ms |
14572 KB |
Output is correct |
46 |
Correct |
262 ms |
14596 KB |
Output is correct |
47 |
Correct |
272 ms |
14604 KB |
Output is correct |
48 |
Correct |
267 ms |
14608 KB |
Output is correct |
49 |
Correct |
286 ms |
14536 KB |
Output is correct |
50 |
Correct |
289 ms |
14544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
7424 KB |
Output is correct |
2 |
Correct |
5 ms |
7424 KB |
Output is correct |
3 |
Correct |
6 ms |
7424 KB |
Output is correct |
4 |
Correct |
5 ms |
7424 KB |
Output is correct |
5 |
Correct |
5 ms |
7424 KB |
Output is correct |
6 |
Correct |
5 ms |
7424 KB |
Output is correct |
7 |
Correct |
6 ms |
7424 KB |
Output is correct |
8 |
Correct |
5 ms |
7424 KB |
Output is correct |
9 |
Correct |
5 ms |
7424 KB |
Output is correct |
10 |
Correct |
5 ms |
7424 KB |
Output is correct |
11 |
Correct |
5 ms |
7424 KB |
Output is correct |
12 |
Correct |
6 ms |
7424 KB |
Output is correct |
13 |
Correct |
5 ms |
7424 KB |
Output is correct |
14 |
Correct |
5 ms |
7424 KB |
Output is correct |
15 |
Correct |
5 ms |
7424 KB |
Output is correct |
16 |
Correct |
6 ms |
7424 KB |
Output is correct |
17 |
Correct |
5 ms |
7424 KB |
Output is correct |
18 |
Correct |
6 ms |
7424 KB |
Output is correct |
19 |
Correct |
9 ms |
7884 KB |
Output is correct |
20 |
Correct |
9 ms |
7808 KB |
Output is correct |
21 |
Correct |
9 ms |
7808 KB |
Output is correct |
22 |
Correct |
18 ms |
7936 KB |
Output is correct |
23 |
Correct |
19 ms |
7680 KB |
Output is correct |
24 |
Correct |
18 ms |
7680 KB |
Output is correct |
25 |
Correct |
17 ms |
7680 KB |
Output is correct |
26 |
Correct |
17 ms |
7680 KB |
Output is correct |
27 |
Correct |
259 ms |
30308 KB |
Output is correct |
28 |
Correct |
249 ms |
28172 KB |
Output is correct |
29 |
Correct |
235 ms |
27616 KB |
Output is correct |
30 |
Correct |
237 ms |
31324 KB |
Output is correct |
31 |
Correct |
293 ms |
21864 KB |
Output is correct |
32 |
Correct |
642 ms |
24796 KB |
Output is correct |
33 |
Correct |
339 ms |
22368 KB |
Output is correct |
34 |
Correct |
391 ms |
22620 KB |
Output is correct |
35 |
Correct |
5 ms |
7424 KB |
Output is correct |
36 |
Correct |
353 ms |
14712 KB |
Output is correct |
37 |
Correct |
1213 ms |
29564 KB |
Output is correct |
38 |
Correct |
1228 ms |
29364 KB |
Output is correct |
39 |
Correct |
1164 ms |
27396 KB |
Output is correct |
40 |
Correct |
469 ms |
17508 KB |
Output is correct |
41 |
Correct |
219 ms |
12776 KB |
Output is correct |
42 |
Correct |
44 ms |
8564 KB |
Output is correct |
43 |
Correct |
1376 ms |
29148 KB |
Output is correct |
44 |
Correct |
1053 ms |
27136 KB |
Output is correct |
45 |
Correct |
1075 ms |
29356 KB |
Output is correct |
46 |
Correct |
901 ms |
29392 KB |
Output is correct |
47 |
Correct |
446 ms |
22880 KB |
Output is correct |
48 |
Correct |
922 ms |
29532 KB |
Output is correct |
49 |
Correct |
924 ms |
29404 KB |
Output is correct |
50 |
Correct |
338 ms |
21676 KB |
Output is correct |
51 |
Correct |
13 ms |
8192 KB |
Output is correct |
52 |
Correct |
13 ms |
8192 KB |
Output is correct |
53 |
Correct |
15 ms |
8192 KB |
Output is correct |
54 |
Correct |
35 ms |
8064 KB |
Output is correct |
55 |
Correct |
32 ms |
8064 KB |
Output is correct |
56 |
Correct |
32 ms |
8096 KB |
Output is correct |
57 |
Correct |
96 ms |
14060 KB |
Output is correct |
58 |
Correct |
97 ms |
14188 KB |
Output is correct |
59 |
Correct |
99 ms |
14188 KB |
Output is correct |
60 |
Correct |
335 ms |
14700 KB |
Output is correct |
61 |
Correct |
337 ms |
14572 KB |
Output is correct |
62 |
Correct |
346 ms |
14696 KB |
Output is correct |
63 |
Correct |
373 ms |
15468 KB |
Output is correct |
64 |
Correct |
353 ms |
15360 KB |
Output is correct |
65 |
Correct |
337 ms |
15340 KB |
Output is correct |
66 |
Correct |
232 ms |
14568 KB |
Output is correct |
67 |
Correct |
286 ms |
14536 KB |
Output is correct |
68 |
Correct |
288 ms |
14568 KB |
Output is correct |
69 |
Correct |
263 ms |
14572 KB |
Output is correct |
70 |
Correct |
262 ms |
14596 KB |
Output is correct |
71 |
Correct |
272 ms |
14604 KB |
Output is correct |
72 |
Correct |
267 ms |
14608 KB |
Output is correct |
73 |
Correct |
286 ms |
14536 KB |
Output is correct |
74 |
Correct |
289 ms |
14544 KB |
Output is correct |
75 |
Correct |
308 ms |
30752 KB |
Output is correct |
76 |
Correct |
318 ms |
27912 KB |
Output is correct |
77 |
Correct |
303 ms |
30556 KB |
Output is correct |
78 |
Correct |
288 ms |
30564 KB |
Output is correct |
79 |
Correct |
342 ms |
22752 KB |
Output is correct |
80 |
Correct |
250 ms |
30308 KB |
Output is correct |
81 |
Correct |
1216 ms |
29276 KB |
Output is correct |
82 |
Correct |
1184 ms |
29404 KB |
Output is correct |
83 |
Correct |
1195 ms |
29296 KB |
Output is correct |
84 |
Correct |
1246 ms |
29332 KB |
Output is correct |
85 |
Correct |
1252 ms |
29416 KB |
Output is correct |
86 |
Correct |
1210 ms |
29372 KB |
Output is correct |
87 |
Correct |
1281 ms |
29308 KB |
Output is correct |
88 |
Correct |
1168 ms |
32616 KB |
Output is correct |
89 |
Correct |
1155 ms |
32600 KB |
Output is correct |
90 |
Correct |
1156 ms |
31376 KB |
Output is correct |
91 |
Correct |
1134 ms |
31368 KB |
Output is correct |
92 |
Correct |
1152 ms |
31560 KB |
Output is correct |
93 |
Correct |
998 ms |
29404 KB |
Output is correct |
94 |
Correct |
1004 ms |
29388 KB |
Output is correct |
95 |
Correct |
1006 ms |
29532 KB |
Output is correct |
96 |
Correct |
1010 ms |
29436 KB |
Output is correct |
97 |
Correct |
1241 ms |
29404 KB |
Output is correct |
98 |
Correct |
733 ms |
25948 KB |
Output is correct |
99 |
Correct |
1000 ms |
29408 KB |
Output is correct |
100 |
Correct |
971 ms |
29404 KB |
Output is correct |
101 |
Correct |
1071 ms |
27332 KB |
Output is correct |
102 |
Correct |
1055 ms |
29224 KB |
Output is correct |
103 |
Correct |
1220 ms |
29212 KB |
Output is correct |
104 |
Correct |
1010 ms |
29420 KB |
Output is correct |
105 |
Correct |
947 ms |
29112 KB |
Output is correct |
106 |
Correct |
887 ms |
28868 KB |
Output is correct |
107 |
Correct |
914 ms |
28800 KB |
Output is correct |
108 |
Correct |
882 ms |
28688 KB |
Output is correct |
109 |
Correct |
883 ms |
28776 KB |
Output is correct |
110 |
Correct |
896 ms |
28764 KB |
Output is correct |
111 |
Correct |
875 ms |
28876 KB |
Output is correct |
112 |
Correct |
982 ms |
28724 KB |
Output is correct |
113 |
Correct |
950 ms |
28764 KB |
Output is correct |
114 |
Correct |
891 ms |
28764 KB |
Output is correct |
115 |
Correct |
882 ms |
28728 KB |
Output is correct |
116 |
Correct |
844 ms |
28728 KB |
Output is correct |