#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
const int N = 3e5 + 5;
int n, x[N], y[N], r[N], a[N];
int kill_[N], bound;
inline bool cmp(int xx, int yy){
return r[xx] > r[yy] || (r[xx] == r[yy] && xx < yy);
}
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(pair <int, int> x) const {
static const uint64_t FIXED_RANDOM1 = chrono::steady_clock::now().time_since_epoch().count();
static const uint64_t FIXED_RANDOM2 = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x.first + FIXED_RANDOM1) ^ splitmix64(x.second + FIXED_RANDOM2);
}
};
gp_hash_table < pair < int, int >, vector < int >, custom_hash > q;
inline void update(){
q.clear();
for(int i = 1; i <= n; i++){
if(!kill_[i]){
q[make_pair(x[i] / bound, y[i] / bound)].push_back(i);
}
}
}
inline bool intersect(int i, int j){
return 1LL * (x[i] - x[j]) * (x[i] - x[j])
+
1LL * (y[i] - y[j]) * (y[i] - y[j])
<=
1LL * (r[i] + r[j]) * (r[i] + r[j]);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x[i] >> y[i] >> r[i];
a[i] = i;
}
sort(a + 1, a + n + 1, cmp);
bound = 2e9 + 5;
int pos = 1;
while(true){
while(pos <= n && kill_[a[pos]]){
pos += 1;
}
if(pos == n + 1){
break;
}
int cur = a[pos];
if(2 * r[cur] <= bound){
bound = r[cur];
update();
}
kill_[cur] = cur;
int xx = x[cur] / bound,
yy = y[cur] / bound;
for(int i = xx - 2; i <= xx + 2; i++){
for(int j = yy - 2; j <= yy + 2; j++){
if(q.find(make_pair(i, j)) != q.end()){
vector < int > nq;
for(auto it : q[make_pair(i, j)]){
if(intersect(cur, it)){
kill_[it] = cur;
}
else{
nq.push_back(it);
}
}
q[make_pair(i, j)] = nq;
}
}
}
}
for(int i = 1; i <= n; i++){
cout << kill_[i] << " ";
}
}
/**
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
640 KB |
Output is correct |
20 |
Correct |
5 ms |
512 KB |
Output is correct |
21 |
Correct |
7 ms |
512 KB |
Output is correct |
22 |
Correct |
18 ms |
1756 KB |
Output is correct |
23 |
Correct |
13 ms |
1628 KB |
Output is correct |
24 |
Correct |
16 ms |
1628 KB |
Output is correct |
25 |
Correct |
11 ms |
1628 KB |
Output is correct |
26 |
Correct |
11 ms |
1756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
214 ms |
8640 KB |
Output is correct |
2 |
Correct |
191 ms |
9108 KB |
Output is correct |
3 |
Correct |
284 ms |
9676 KB |
Output is correct |
4 |
Correct |
187 ms |
8440 KB |
Output is correct |
5 |
Correct |
234 ms |
8848 KB |
Output is correct |
6 |
Correct |
701 ms |
44084 KB |
Output is correct |
7 |
Correct |
284 ms |
11112 KB |
Output is correct |
8 |
Correct |
379 ms |
14852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
346 ms |
21368 KB |
Output is correct |
3 |
Correct |
1593 ms |
91320 KB |
Output is correct |
4 |
Correct |
1499 ms |
91092 KB |
Output is correct |
5 |
Correct |
1398 ms |
60444 KB |
Output is correct |
6 |
Correct |
512 ms |
30948 KB |
Output is correct |
7 |
Correct |
205 ms |
15864 KB |
Output is correct |
8 |
Correct |
28 ms |
3688 KB |
Output is correct |
9 |
Correct |
1650 ms |
91220 KB |
Output is correct |
10 |
Correct |
1182 ms |
60848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1285 ms |
83016 KB |
Output is correct |
2 |
Correct |
1402 ms |
90384 KB |
Output is correct |
3 |
Correct |
510 ms |
33000 KB |
Output is correct |
4 |
Correct |
1256 ms |
90488 KB |
Output is correct |
5 |
Correct |
1247 ms |
90616 KB |
Output is correct |
6 |
Correct |
261 ms |
19612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
640 KB |
Output is correct |
20 |
Correct |
5 ms |
512 KB |
Output is correct |
21 |
Correct |
7 ms |
512 KB |
Output is correct |
22 |
Correct |
18 ms |
1756 KB |
Output is correct |
23 |
Correct |
13 ms |
1628 KB |
Output is correct |
24 |
Correct |
16 ms |
1628 KB |
Output is correct |
25 |
Correct |
11 ms |
1628 KB |
Output is correct |
26 |
Correct |
11 ms |
1756 KB |
Output is correct |
27 |
Correct |
11 ms |
768 KB |
Output is correct |
28 |
Correct |
10 ms |
728 KB |
Output is correct |
29 |
Correct |
7 ms |
640 KB |
Output is correct |
30 |
Correct |
24 ms |
3096 KB |
Output is correct |
31 |
Correct |
22 ms |
2968 KB |
Output is correct |
32 |
Correct |
26 ms |
2960 KB |
Output is correct |
33 |
Correct |
89 ms |
3572 KB |
Output is correct |
34 |
Correct |
68 ms |
3576 KB |
Output is correct |
35 |
Correct |
76 ms |
3060 KB |
Output is correct |
36 |
Correct |
427 ms |
21476 KB |
Output is correct |
37 |
Correct |
405 ms |
24064 KB |
Output is correct |
38 |
Correct |
474 ms |
24260 KB |
Output is correct |
39 |
Correct |
324 ms |
22832 KB |
Output is correct |
40 |
Correct |
350 ms |
22928 KB |
Output is correct |
41 |
Correct |
330 ms |
22760 KB |
Output is correct |
42 |
Correct |
228 ms |
23168 KB |
Output is correct |
43 |
Correct |
328 ms |
24060 KB |
Output is correct |
44 |
Correct |
345 ms |
24064 KB |
Output is correct |
45 |
Correct |
334 ms |
24064 KB |
Output is correct |
46 |
Correct |
357 ms |
24032 KB |
Output is correct |
47 |
Correct |
333 ms |
24036 KB |
Output is correct |
48 |
Correct |
315 ms |
24056 KB |
Output is correct |
49 |
Correct |
326 ms |
24136 KB |
Output is correct |
50 |
Correct |
370 ms |
24040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
640 KB |
Output is correct |
20 |
Correct |
5 ms |
512 KB |
Output is correct |
21 |
Correct |
7 ms |
512 KB |
Output is correct |
22 |
Correct |
18 ms |
1756 KB |
Output is correct |
23 |
Correct |
13 ms |
1628 KB |
Output is correct |
24 |
Correct |
16 ms |
1628 KB |
Output is correct |
25 |
Correct |
11 ms |
1628 KB |
Output is correct |
26 |
Correct |
11 ms |
1756 KB |
Output is correct |
27 |
Correct |
214 ms |
8640 KB |
Output is correct |
28 |
Correct |
191 ms |
9108 KB |
Output is correct |
29 |
Correct |
284 ms |
9676 KB |
Output is correct |
30 |
Correct |
187 ms |
8440 KB |
Output is correct |
31 |
Correct |
234 ms |
8848 KB |
Output is correct |
32 |
Correct |
701 ms |
44084 KB |
Output is correct |
33 |
Correct |
284 ms |
11112 KB |
Output is correct |
34 |
Correct |
379 ms |
14852 KB |
Output is correct |
35 |
Correct |
3 ms |
384 KB |
Output is correct |
36 |
Correct |
346 ms |
21368 KB |
Output is correct |
37 |
Correct |
1593 ms |
91320 KB |
Output is correct |
38 |
Correct |
1499 ms |
91092 KB |
Output is correct |
39 |
Correct |
1398 ms |
60444 KB |
Output is correct |
40 |
Correct |
512 ms |
30948 KB |
Output is correct |
41 |
Correct |
205 ms |
15864 KB |
Output is correct |
42 |
Correct |
28 ms |
3688 KB |
Output is correct |
43 |
Correct |
1650 ms |
91220 KB |
Output is correct |
44 |
Correct |
1182 ms |
60848 KB |
Output is correct |
45 |
Correct |
1285 ms |
83016 KB |
Output is correct |
46 |
Correct |
1402 ms |
90384 KB |
Output is correct |
47 |
Correct |
510 ms |
33000 KB |
Output is correct |
48 |
Correct |
1256 ms |
90488 KB |
Output is correct |
49 |
Correct |
1247 ms |
90616 KB |
Output is correct |
50 |
Correct |
261 ms |
19612 KB |
Output is correct |
51 |
Correct |
11 ms |
768 KB |
Output is correct |
52 |
Correct |
10 ms |
728 KB |
Output is correct |
53 |
Correct |
7 ms |
640 KB |
Output is correct |
54 |
Correct |
24 ms |
3096 KB |
Output is correct |
55 |
Correct |
22 ms |
2968 KB |
Output is correct |
56 |
Correct |
26 ms |
2960 KB |
Output is correct |
57 |
Correct |
89 ms |
3572 KB |
Output is correct |
58 |
Correct |
68 ms |
3576 KB |
Output is correct |
59 |
Correct |
76 ms |
3060 KB |
Output is correct |
60 |
Correct |
427 ms |
21476 KB |
Output is correct |
61 |
Correct |
405 ms |
24064 KB |
Output is correct |
62 |
Correct |
474 ms |
24260 KB |
Output is correct |
63 |
Correct |
324 ms |
22832 KB |
Output is correct |
64 |
Correct |
350 ms |
22928 KB |
Output is correct |
65 |
Correct |
330 ms |
22760 KB |
Output is correct |
66 |
Correct |
228 ms |
23168 KB |
Output is correct |
67 |
Correct |
328 ms |
24060 KB |
Output is correct |
68 |
Correct |
345 ms |
24064 KB |
Output is correct |
69 |
Correct |
334 ms |
24064 KB |
Output is correct |
70 |
Correct |
357 ms |
24032 KB |
Output is correct |
71 |
Correct |
333 ms |
24036 KB |
Output is correct |
72 |
Correct |
315 ms |
24056 KB |
Output is correct |
73 |
Correct |
326 ms |
24136 KB |
Output is correct |
74 |
Correct |
370 ms |
24040 KB |
Output is correct |
75 |
Correct |
208 ms |
18000 KB |
Output is correct |
76 |
Correct |
194 ms |
17404 KB |
Output is correct |
77 |
Correct |
203 ms |
18748 KB |
Output is correct |
78 |
Correct |
194 ms |
18452 KB |
Output is correct |
79 |
Correct |
240 ms |
17148 KB |
Output is correct |
80 |
Correct |
202 ms |
18284 KB |
Output is correct |
81 |
Correct |
1623 ms |
91148 KB |
Output is correct |
82 |
Correct |
1531 ms |
91092 KB |
Output is correct |
83 |
Correct |
1522 ms |
91024 KB |
Output is correct |
84 |
Correct |
1624 ms |
91476 KB |
Output is correct |
85 |
Correct |
1563 ms |
91164 KB |
Output is correct |
86 |
Correct |
1548 ms |
91128 KB |
Output is correct |
87 |
Correct |
1535 ms |
91296 KB |
Output is correct |
88 |
Correct |
1148 ms |
47792 KB |
Output is correct |
89 |
Correct |
1228 ms |
47756 KB |
Output is correct |
90 |
Correct |
1239 ms |
47892 KB |
Output is correct |
91 |
Correct |
1272 ms |
47944 KB |
Output is correct |
92 |
Correct |
1369 ms |
47900 KB |
Output is correct |
93 |
Correct |
1354 ms |
89940 KB |
Output is correct |
94 |
Correct |
1380 ms |
90580 KB |
Output is correct |
95 |
Correct |
1237 ms |
90060 KB |
Output is correct |
96 |
Correct |
1564 ms |
90200 KB |
Output is correct |
97 |
Correct |
1568 ms |
89872 KB |
Output is correct |
98 |
Correct |
905 ms |
51432 KB |
Output is correct |
99 |
Correct |
1550 ms |
90128 KB |
Output is correct |
100 |
Correct |
1490 ms |
90056 KB |
Output is correct |
101 |
Correct |
1042 ms |
51308 KB |
Output is correct |
102 |
Correct |
1529 ms |
90356 KB |
Output is correct |
103 |
Correct |
1565 ms |
90068 KB |
Output is correct |
104 |
Correct |
1506 ms |
89812 KB |
Output is correct |
105 |
Correct |
976 ms |
88060 KB |
Output is correct |
106 |
Correct |
1150 ms |
90836 KB |
Output is correct |
107 |
Correct |
1115 ms |
91020 KB |
Output is correct |
108 |
Correct |
1196 ms |
91036 KB |
Output is correct |
109 |
Correct |
1226 ms |
90820 KB |
Output is correct |
110 |
Correct |
1250 ms |
91064 KB |
Output is correct |
111 |
Correct |
1123 ms |
90888 KB |
Output is correct |
112 |
Correct |
1155 ms |
90836 KB |
Output is correct |
113 |
Correct |
1208 ms |
90964 KB |
Output is correct |
114 |
Correct |
1134 ms |
90852 KB |
Output is correct |
115 |
Correct |
1094 ms |
90836 KB |
Output is correct |
116 |
Correct |
1235 ms |
90908 KB |
Output is correct |