#include<bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define int ll
using ld = long double;
using pii = pair<int, int>;
#define F first
#define S second
const ld PI = 3.1415926535;
const int N = 5e5 + 2;
const int M = 2e6 + 1;
int mod = 998244353;
const int infi = INT_MAX;
const ll infl = LLONG_MAX;
int mult(int a, int b) {
return a * 1LL * b % mod;
}
int sum(int a, int b) {
if (a + b < 0)
return a + b + mod;
if (a + b >= mod)
return a + b - mod;
return a + b;
}
ll binpow(ll a, ll n) {
if (n == 0)
return 1;
if (n % 2 == 1) {
return binpow(a, n - 1) * a % mod;
} else {
ll b = binpow(a, n / 2);
return b * b % mod;
}
}
int n, ans[N], x[N], y[N], r[N];
int csz = 1e9+1;
set<pair<pii, pii>> cs;
vector<pii> sps;
vector<vector<pair<pii, pii>>> mp;
pii get(int x, int y){
return {floor((ld)x / (ld)csz), floor((ld)y / (ld)csz)};
}
bool inter(pair<pii, pii> a, pair<pii, pii> b){
return (((a.S.F - b.S.F) * (a.S.F - b.S.F) + (a.S.S - b.S.S) * (a.S.S - b.S.S)) <= (a.F.F + b.F.F) * (a.F.F + b.F.F));
}
void solve() {
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x[i] >> y[i] >> r[i];
cs.insert({{r[i], n - i + 1}, {x[i], y[i]}});
sps.push_back(get(x[i], y[i]));
}
sort(sps.begin(), sps.end());
sps.resize(unique(sps.begin(), sps.end()) - sps.begin());
mp.resize(sps.size());
for(int i = 1; i <= n; i++){
mp[lower_bound(sps.begin(), sps.end(), get(x[i], y[i])) - sps.begin()].push_back({{r[i], n - i + 1}, {x[i], y[i]}});
}
while(cs.size() > 0){
auto e = *cs.rbegin();
cs.erase(e);
if(e.F.F <= csz / 2){
csz = e.F.F;
sps.clear();
for(auto e : mp){
for(auto crc : e){
sps.push_back(get(crc.S.F, crc.S.S));
}
}
sort(sps.begin(), sps.end());
sps.resize(unique(sps.begin(), sps.end()) - sps.begin());
mp.assign(sps.size(), vector<pair<pii, pii>>());
for(int i = 1; i <= n; i++){
if(ans[i] == 0){
mp[lower_bound(sps.begin(), sps.end(), get(x[i], y[i])) - sps.begin()].push_back({{r[i], n - i + 1}, {x[i], y[i]}});
}
}
}
ans[n - e.F.S + 1] = n - e.F.S + 1;
pii bl = get(e.S.F, e.S.S);
for(int x = bl.F - 2; x <= bl.F + 2; x++){
for(int y = bl.S - 2; y <= bl.S + 2; y++){
auto ps = lower_bound(sps.begin(), sps.end(), make_pair(x, y));
if(ps == sps.end() || *ps != make_pair(x, y))
continue;
for(auto crc : mp[ps - sps.begin()]){
if(inter(crc, e)){
if(ans[n - crc.F.S + 1] == 0){
ans[n - crc.F.S + 1] = n - e.F.S + 1;
cs.erase(crc);
}
}
}
}
}
}
for(int i = 1; i <= n; i++)
cout << ans[i] << ' ';
cout << '\n';
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4432 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
6480 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
6480 KB |
Output is correct |
9 |
Correct |
1 ms |
4432 KB |
Output is correct |
10 |
Correct |
1 ms |
4432 KB |
Output is correct |
11 |
Correct |
1 ms |
4604 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4432 KB |
Output is correct |
14 |
Correct |
1 ms |
4432 KB |
Output is correct |
15 |
Correct |
1 ms |
4604 KB |
Output is correct |
16 |
Correct |
2 ms |
6736 KB |
Output is correct |
17 |
Correct |
2 ms |
4688 KB |
Output is correct |
18 |
Correct |
2 ms |
4688 KB |
Output is correct |
19 |
Correct |
5 ms |
7248 KB |
Output is correct |
20 |
Correct |
5 ms |
7372 KB |
Output is correct |
21 |
Correct |
7 ms |
7504 KB |
Output is correct |
22 |
Correct |
15 ms |
5580 KB |
Output is correct |
23 |
Correct |
17 ms |
5580 KB |
Output is correct |
24 |
Correct |
15 ms |
5488 KB |
Output is correct |
25 |
Correct |
15 ms |
5340 KB |
Output is correct |
26 |
Correct |
16 ms |
5456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
576 ms |
62632 KB |
Output is correct |
2 |
Correct |
621 ms |
65664 KB |
Output is correct |
3 |
Correct |
539 ms |
63660 KB |
Output is correct |
4 |
Correct |
591 ms |
69800 KB |
Output is correct |
5 |
Correct |
603 ms |
60188 KB |
Output is correct |
6 |
Correct |
883 ms |
68988 KB |
Output is correct |
7 |
Correct |
656 ms |
61660 KB |
Output is correct |
8 |
Correct |
690 ms |
65140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4600 KB |
Output is correct |
2 |
Correct |
406 ms |
30816 KB |
Output is correct |
3 |
Correct |
1231 ms |
70888 KB |
Output is correct |
4 |
Correct |
1306 ms |
79028 KB |
Output is correct |
5 |
Correct |
1410 ms |
75056 KB |
Output is correct |
6 |
Correct |
582 ms |
45384 KB |
Output is correct |
7 |
Correct |
275 ms |
28852 KB |
Output is correct |
8 |
Correct |
44 ms |
8332 KB |
Output is correct |
9 |
Correct |
1485 ms |
78780 KB |
Output is correct |
10 |
Correct |
1281 ms |
76180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
864 ms |
67240 KB |
Output is correct |
2 |
Correct |
797 ms |
65856 KB |
Output is correct |
3 |
Correct |
643 ms |
63656 KB |
Output is correct |
4 |
Correct |
817 ms |
69736 KB |
Output is correct |
5 |
Correct |
814 ms |
65876 KB |
Output is correct |
6 |
Correct |
555 ms |
63912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4432 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
6480 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
6480 KB |
Output is correct |
9 |
Correct |
1 ms |
4432 KB |
Output is correct |
10 |
Correct |
1 ms |
4432 KB |
Output is correct |
11 |
Correct |
1 ms |
4604 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4432 KB |
Output is correct |
14 |
Correct |
1 ms |
4432 KB |
Output is correct |
15 |
Correct |
1 ms |
4604 KB |
Output is correct |
16 |
Correct |
2 ms |
6736 KB |
Output is correct |
17 |
Correct |
2 ms |
4688 KB |
Output is correct |
18 |
Correct |
2 ms |
4688 KB |
Output is correct |
19 |
Correct |
5 ms |
7248 KB |
Output is correct |
20 |
Correct |
5 ms |
7372 KB |
Output is correct |
21 |
Correct |
7 ms |
7504 KB |
Output is correct |
22 |
Correct |
15 ms |
5580 KB |
Output is correct |
23 |
Correct |
17 ms |
5580 KB |
Output is correct |
24 |
Correct |
15 ms |
5488 KB |
Output is correct |
25 |
Correct |
15 ms |
5340 KB |
Output is correct |
26 |
Correct |
16 ms |
5456 KB |
Output is correct |
27 |
Correct |
18 ms |
6236 KB |
Output is correct |
28 |
Correct |
17 ms |
6356 KB |
Output is correct |
29 |
Correct |
14 ms |
6780 KB |
Output is correct |
30 |
Correct |
36 ms |
6536 KB |
Output is correct |
31 |
Correct |
32 ms |
6868 KB |
Output is correct |
32 |
Correct |
32 ms |
6356 KB |
Output is correct |
33 |
Correct |
130 ms |
27696 KB |
Output is correct |
34 |
Correct |
111 ms |
27700 KB |
Output is correct |
35 |
Correct |
190 ms |
29752 KB |
Output is correct |
36 |
Correct |
376 ms |
31472 KB |
Output is correct |
37 |
Correct |
379 ms |
33012 KB |
Output is correct |
38 |
Correct |
392 ms |
31476 KB |
Output is correct |
39 |
Correct |
828 ms |
31712 KB |
Output is correct |
40 |
Correct |
827 ms |
31492 KB |
Output is correct |
41 |
Correct |
783 ms |
32376 KB |
Output is correct |
42 |
Correct |
227 ms |
29036 KB |
Output is correct |
43 |
Correct |
251 ms |
30600 KB |
Output is correct |
44 |
Correct |
254 ms |
30612 KB |
Output is correct |
45 |
Correct |
244 ms |
28972 KB |
Output is correct |
46 |
Correct |
262 ms |
29036 KB |
Output is correct |
47 |
Correct |
255 ms |
29120 KB |
Output is correct |
48 |
Correct |
260 ms |
29000 KB |
Output is correct |
49 |
Correct |
239 ms |
30624 KB |
Output is correct |
50 |
Correct |
243 ms |
30576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4432 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
6480 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
6480 KB |
Output is correct |
9 |
Correct |
1 ms |
4432 KB |
Output is correct |
10 |
Correct |
1 ms |
4432 KB |
Output is correct |
11 |
Correct |
1 ms |
4604 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4432 KB |
Output is correct |
14 |
Correct |
1 ms |
4432 KB |
Output is correct |
15 |
Correct |
1 ms |
4604 KB |
Output is correct |
16 |
Correct |
2 ms |
6736 KB |
Output is correct |
17 |
Correct |
2 ms |
4688 KB |
Output is correct |
18 |
Correct |
2 ms |
4688 KB |
Output is correct |
19 |
Correct |
5 ms |
7248 KB |
Output is correct |
20 |
Correct |
5 ms |
7372 KB |
Output is correct |
21 |
Correct |
7 ms |
7504 KB |
Output is correct |
22 |
Correct |
15 ms |
5580 KB |
Output is correct |
23 |
Correct |
17 ms |
5580 KB |
Output is correct |
24 |
Correct |
15 ms |
5488 KB |
Output is correct |
25 |
Correct |
15 ms |
5340 KB |
Output is correct |
26 |
Correct |
16 ms |
5456 KB |
Output is correct |
27 |
Correct |
576 ms |
62632 KB |
Output is correct |
28 |
Correct |
621 ms |
65664 KB |
Output is correct |
29 |
Correct |
539 ms |
63660 KB |
Output is correct |
30 |
Correct |
591 ms |
69800 KB |
Output is correct |
31 |
Correct |
603 ms |
60188 KB |
Output is correct |
32 |
Correct |
883 ms |
68988 KB |
Output is correct |
33 |
Correct |
656 ms |
61660 KB |
Output is correct |
34 |
Correct |
690 ms |
65140 KB |
Output is correct |
35 |
Correct |
1 ms |
4600 KB |
Output is correct |
36 |
Correct |
406 ms |
30816 KB |
Output is correct |
37 |
Correct |
1231 ms |
70888 KB |
Output is correct |
38 |
Correct |
1306 ms |
79028 KB |
Output is correct |
39 |
Correct |
1410 ms |
75056 KB |
Output is correct |
40 |
Correct |
582 ms |
45384 KB |
Output is correct |
41 |
Correct |
275 ms |
28852 KB |
Output is correct |
42 |
Correct |
44 ms |
8332 KB |
Output is correct |
43 |
Correct |
1485 ms |
78780 KB |
Output is correct |
44 |
Correct |
1281 ms |
76180 KB |
Output is correct |
45 |
Correct |
864 ms |
67240 KB |
Output is correct |
46 |
Correct |
797 ms |
65856 KB |
Output is correct |
47 |
Correct |
643 ms |
63656 KB |
Output is correct |
48 |
Correct |
817 ms |
69736 KB |
Output is correct |
49 |
Correct |
814 ms |
65876 KB |
Output is correct |
50 |
Correct |
555 ms |
63912 KB |
Output is correct |
51 |
Correct |
18 ms |
6236 KB |
Output is correct |
52 |
Correct |
17 ms |
6356 KB |
Output is correct |
53 |
Correct |
14 ms |
6780 KB |
Output is correct |
54 |
Correct |
36 ms |
6536 KB |
Output is correct |
55 |
Correct |
32 ms |
6868 KB |
Output is correct |
56 |
Correct |
32 ms |
6356 KB |
Output is correct |
57 |
Correct |
130 ms |
27696 KB |
Output is correct |
58 |
Correct |
111 ms |
27700 KB |
Output is correct |
59 |
Correct |
190 ms |
29752 KB |
Output is correct |
60 |
Correct |
376 ms |
31472 KB |
Output is correct |
61 |
Correct |
379 ms |
33012 KB |
Output is correct |
62 |
Correct |
392 ms |
31476 KB |
Output is correct |
63 |
Correct |
828 ms |
31712 KB |
Output is correct |
64 |
Correct |
827 ms |
31492 KB |
Output is correct |
65 |
Correct |
783 ms |
32376 KB |
Output is correct |
66 |
Correct |
227 ms |
29036 KB |
Output is correct |
67 |
Correct |
251 ms |
30600 KB |
Output is correct |
68 |
Correct |
254 ms |
30612 KB |
Output is correct |
69 |
Correct |
244 ms |
28972 KB |
Output is correct |
70 |
Correct |
262 ms |
29036 KB |
Output is correct |
71 |
Correct |
255 ms |
29120 KB |
Output is correct |
72 |
Correct |
260 ms |
29000 KB |
Output is correct |
73 |
Correct |
239 ms |
30624 KB |
Output is correct |
74 |
Correct |
243 ms |
30576 KB |
Output is correct |
75 |
Correct |
627 ms |
73652 KB |
Output is correct |
76 |
Correct |
601 ms |
72300 KB |
Output is correct |
77 |
Correct |
574 ms |
73592 KB |
Output is correct |
78 |
Correct |
481 ms |
68120 KB |
Output is correct |
79 |
Correct |
665 ms |
68832 KB |
Output is correct |
80 |
Correct |
442 ms |
68136 KB |
Output is correct |
81 |
Correct |
1448 ms |
79096 KB |
Output is correct |
82 |
Correct |
1384 ms |
80808 KB |
Output is correct |
83 |
Correct |
1408 ms |
78752 KB |
Output is correct |
84 |
Correct |
1479 ms |
81340 KB |
Output is correct |
85 |
Correct |
1281 ms |
78900 KB |
Output is correct |
86 |
Correct |
1288 ms |
80904 KB |
Output is correct |
87 |
Correct |
1478 ms |
80988 KB |
Output is correct |
88 |
Correct |
2752 ms |
82448 KB |
Output is correct |
89 |
Correct |
2513 ms |
80460 KB |
Output is correct |
90 |
Correct |
2592 ms |
80272 KB |
Output is correct |
91 |
Correct |
2466 ms |
86436 KB |
Output is correct |
92 |
Correct |
2520 ms |
77808 KB |
Output is correct |
93 |
Correct |
1277 ms |
79880 KB |
Output is correct |
94 |
Correct |
1299 ms |
80164 KB |
Output is correct |
95 |
Correct |
1096 ms |
79952 KB |
Output is correct |
96 |
Correct |
1170 ms |
79988 KB |
Output is correct |
97 |
Correct |
1278 ms |
77720 KB |
Output is correct |
98 |
Correct |
945 ms |
75584 KB |
Output is correct |
99 |
Correct |
1154 ms |
77992 KB |
Output is correct |
100 |
Correct |
1138 ms |
77688 KB |
Output is correct |
101 |
Correct |
1173 ms |
77652 KB |
Output is correct |
102 |
Correct |
1113 ms |
79628 KB |
Output is correct |
103 |
Correct |
1310 ms |
79648 KB |
Output is correct |
104 |
Correct |
1136 ms |
79748 KB |
Output is correct |
105 |
Correct |
873 ms |
70568 KB |
Output is correct |
106 |
Correct |
795 ms |
75056 KB |
Output is correct |
107 |
Correct |
799 ms |
72836 KB |
Output is correct |
108 |
Correct |
827 ms |
72880 KB |
Output is correct |
109 |
Correct |
825 ms |
72856 KB |
Output is correct |
110 |
Correct |
858 ms |
72944 KB |
Output is correct |
111 |
Correct |
845 ms |
72884 KB |
Output is correct |
112 |
Correct |
780 ms |
74152 KB |
Output is correct |
113 |
Correct |
779 ms |
72776 KB |
Output is correct |
114 |
Correct |
791 ms |
72844 KB |
Output is correct |
115 |
Correct |
808 ms |
74156 KB |
Output is correct |
116 |
Correct |
828 ms |
75464 KB |
Output is correct |