#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = (int)3e5 + 10;
ll cut = (1ll << 31);
int sol[N];
ll xi[N];
ll yi[N];
ll ri[N];
ll sq(ll v){
return v * 1ll * v;
}
bool check(int i, int j){
// sqrt((xi-xj)^2+(yi-yj)^2) <= (ri + rj)
ll val = sq(xi[i] - xi[j]) + sq(yi[i] - yi[j]);
ll cmp = sq(ri[i] + ri[j]);
if(val <= cmp)
return true;
return false;
}
map<pii, int> idx;
set<int> V[N];
int cid;
void add(pii x){
if(idx.count(x)) return;
idx[x]=cid;
cid++;
}
int main(){
fastIO;
int n;
cin >> n;
vector<pii> cir;
for(int i = 1; i <= n; i ++ ){
cin >> xi[i] >> yi[i] >> ri[i];
cir.push_back({ri[i], -i});
}
sort(cir.begin(), cir.end());
int id;
bool has;
ll ci, cj;
int gg;
for(int i = cir.size() - 1; i >= 0 ;i -- ){
id = -cir[i].se;
if(sol[id] == 0){
has=false;
while(cut/2ll >= ri[id]){
has=true;
cut /= 2ll;
}
if(has){
idx.clear();
for(int i = 0 ; i < cid; i ++ ){
V[i].clear();
}
cid = 0;
for(int i = 1; i <= n; i ++ ){
if(sol[i] == 0){
add(mp(xi[i]/cut, yi[i]/cut));
V[idx[mp(xi[i]/cut,yi[i]/cut)]].insert(i);
}
}
}
ci = xi[id]/cut;
cj = yi[id]/cut;
for(ll p = -2; p <= 2; p ++ ){
for(ll q = -2 ; q <= 2; q ++ ){
if(idx.count(mp(ci+p,cj+q))){
gg = idx[mp(ci + p, cj + q)];
auto it = V[gg].begin();
while(it != V[gg].end()){
if(check(*it,id)){
sol[*it]=id;
it=V[gg].erase(it);
}
else{
it ++ ;
}
}
}
}
}
}
}
for(int i = 1; i <= n; i ++ ){
cout << sol[i] << " ";
}
cout << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
10 ms |
14444 KB |
Output is correct |
4 |
Correct |
12 ms |
14444 KB |
Output is correct |
5 |
Correct |
10 ms |
14444 KB |
Output is correct |
6 |
Correct |
10 ms |
14444 KB |
Output is correct |
7 |
Correct |
10 ms |
14444 KB |
Output is correct |
8 |
Correct |
10 ms |
14464 KB |
Output is correct |
9 |
Correct |
10 ms |
14444 KB |
Output is correct |
10 |
Correct |
10 ms |
14444 KB |
Output is correct |
11 |
Correct |
10 ms |
14444 KB |
Output is correct |
12 |
Correct |
10 ms |
14444 KB |
Output is correct |
13 |
Correct |
10 ms |
14444 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
10 ms |
14444 KB |
Output is correct |
16 |
Correct |
12 ms |
14572 KB |
Output is correct |
17 |
Correct |
13 ms |
14572 KB |
Output is correct |
18 |
Correct |
10 ms |
14572 KB |
Output is correct |
19 |
Correct |
13 ms |
14956 KB |
Output is correct |
20 |
Correct |
14 ms |
14956 KB |
Output is correct |
21 |
Correct |
14 ms |
14956 KB |
Output is correct |
22 |
Correct |
26 ms |
15212 KB |
Output is correct |
23 |
Correct |
29 ms |
15212 KB |
Output is correct |
24 |
Correct |
29 ms |
15360 KB |
Output is correct |
25 |
Correct |
25 ms |
15212 KB |
Output is correct |
26 |
Correct |
27 ms |
15212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
247 ms |
43600 KB |
Output is correct |
2 |
Correct |
257 ms |
43600 KB |
Output is correct |
3 |
Correct |
248 ms |
43396 KB |
Output is correct |
4 |
Correct |
243 ms |
43600 KB |
Output is correct |
5 |
Correct |
536 ms |
43728 KB |
Output is correct |
6 |
Correct |
1119 ms |
50768 KB |
Output is correct |
7 |
Correct |
640 ms |
44112 KB |
Output is correct |
8 |
Correct |
698 ms |
45520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
744 ms |
30308 KB |
Output is correct |
3 |
Correct |
2595 ms |
62288 KB |
Output is correct |
4 |
Correct |
2642 ms |
62208 KB |
Output is correct |
5 |
Correct |
2830 ms |
58576 KB |
Output is correct |
6 |
Correct |
1040 ms |
37084 KB |
Output is correct |
7 |
Correct |
406 ms |
26340 KB |
Output is correct |
8 |
Correct |
52 ms |
17004 KB |
Output is correct |
9 |
Correct |
2976 ms |
61560 KB |
Output is correct |
10 |
Correct |
2421 ms |
65872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1969 ms |
62384 KB |
Output is correct |
2 |
Correct |
1334 ms |
62444 KB |
Output is correct |
3 |
Correct |
781 ms |
46860 KB |
Output is correct |
4 |
Correct |
1412 ms |
62544 KB |
Output is correct |
5 |
Correct |
1389 ms |
62248 KB |
Output is correct |
6 |
Correct |
590 ms |
43344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
10 ms |
14444 KB |
Output is correct |
4 |
Correct |
12 ms |
14444 KB |
Output is correct |
5 |
Correct |
10 ms |
14444 KB |
Output is correct |
6 |
Correct |
10 ms |
14444 KB |
Output is correct |
7 |
Correct |
10 ms |
14444 KB |
Output is correct |
8 |
Correct |
10 ms |
14464 KB |
Output is correct |
9 |
Correct |
10 ms |
14444 KB |
Output is correct |
10 |
Correct |
10 ms |
14444 KB |
Output is correct |
11 |
Correct |
10 ms |
14444 KB |
Output is correct |
12 |
Correct |
10 ms |
14444 KB |
Output is correct |
13 |
Correct |
10 ms |
14444 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
10 ms |
14444 KB |
Output is correct |
16 |
Correct |
12 ms |
14572 KB |
Output is correct |
17 |
Correct |
13 ms |
14572 KB |
Output is correct |
18 |
Correct |
10 ms |
14572 KB |
Output is correct |
19 |
Correct |
13 ms |
14956 KB |
Output is correct |
20 |
Correct |
14 ms |
14956 KB |
Output is correct |
21 |
Correct |
14 ms |
14956 KB |
Output is correct |
22 |
Correct |
26 ms |
15212 KB |
Output is correct |
23 |
Correct |
29 ms |
15212 KB |
Output is correct |
24 |
Correct |
29 ms |
15360 KB |
Output is correct |
25 |
Correct |
25 ms |
15212 KB |
Output is correct |
26 |
Correct |
27 ms |
15212 KB |
Output is correct |
27 |
Correct |
17 ms |
15344 KB |
Output is correct |
28 |
Correct |
17 ms |
15344 KB |
Output is correct |
29 |
Correct |
17 ms |
15344 KB |
Output is correct |
30 |
Correct |
48 ms |
15984 KB |
Output is correct |
31 |
Correct |
49 ms |
15984 KB |
Output is correct |
32 |
Correct |
47 ms |
15984 KB |
Output is correct |
33 |
Correct |
89 ms |
24036 KB |
Output is correct |
34 |
Correct |
89 ms |
24036 KB |
Output is correct |
35 |
Correct |
94 ms |
24036 KB |
Output is correct |
36 |
Correct |
692 ms |
30308 KB |
Output is correct |
37 |
Correct |
677 ms |
30308 KB |
Output is correct |
38 |
Correct |
715 ms |
30308 KB |
Output is correct |
39 |
Correct |
892 ms |
29496 KB |
Output is correct |
40 |
Correct |
886 ms |
29556 KB |
Output is correct |
41 |
Correct |
875 ms |
29540 KB |
Output is correct |
42 |
Correct |
375 ms |
27876 KB |
Output is correct |
43 |
Correct |
370 ms |
30180 KB |
Output is correct |
44 |
Correct |
363 ms |
30180 KB |
Output is correct |
45 |
Correct |
384 ms |
30180 KB |
Output is correct |
46 |
Correct |
357 ms |
30180 KB |
Output is correct |
47 |
Correct |
370 ms |
30180 KB |
Output is correct |
48 |
Correct |
374 ms |
30140 KB |
Output is correct |
49 |
Correct |
362 ms |
30308 KB |
Output is correct |
50 |
Correct |
388 ms |
30180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
10 ms |
14444 KB |
Output is correct |
4 |
Correct |
12 ms |
14444 KB |
Output is correct |
5 |
Correct |
10 ms |
14444 KB |
Output is correct |
6 |
Correct |
10 ms |
14444 KB |
Output is correct |
7 |
Correct |
10 ms |
14444 KB |
Output is correct |
8 |
Correct |
10 ms |
14464 KB |
Output is correct |
9 |
Correct |
10 ms |
14444 KB |
Output is correct |
10 |
Correct |
10 ms |
14444 KB |
Output is correct |
11 |
Correct |
10 ms |
14444 KB |
Output is correct |
12 |
Correct |
10 ms |
14444 KB |
Output is correct |
13 |
Correct |
10 ms |
14444 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
10 ms |
14444 KB |
Output is correct |
16 |
Correct |
12 ms |
14572 KB |
Output is correct |
17 |
Correct |
13 ms |
14572 KB |
Output is correct |
18 |
Correct |
10 ms |
14572 KB |
Output is correct |
19 |
Correct |
13 ms |
14956 KB |
Output is correct |
20 |
Correct |
14 ms |
14956 KB |
Output is correct |
21 |
Correct |
14 ms |
14956 KB |
Output is correct |
22 |
Correct |
26 ms |
15212 KB |
Output is correct |
23 |
Correct |
29 ms |
15212 KB |
Output is correct |
24 |
Correct |
29 ms |
15360 KB |
Output is correct |
25 |
Correct |
25 ms |
15212 KB |
Output is correct |
26 |
Correct |
27 ms |
15212 KB |
Output is correct |
27 |
Correct |
247 ms |
43600 KB |
Output is correct |
28 |
Correct |
257 ms |
43600 KB |
Output is correct |
29 |
Correct |
248 ms |
43396 KB |
Output is correct |
30 |
Correct |
243 ms |
43600 KB |
Output is correct |
31 |
Correct |
536 ms |
43728 KB |
Output is correct |
32 |
Correct |
1119 ms |
50768 KB |
Output is correct |
33 |
Correct |
640 ms |
44112 KB |
Output is correct |
34 |
Correct |
698 ms |
45520 KB |
Output is correct |
35 |
Correct |
10 ms |
14444 KB |
Output is correct |
36 |
Correct |
744 ms |
30308 KB |
Output is correct |
37 |
Correct |
2595 ms |
62288 KB |
Output is correct |
38 |
Correct |
2642 ms |
62208 KB |
Output is correct |
39 |
Correct |
2830 ms |
58576 KB |
Output is correct |
40 |
Correct |
1040 ms |
37084 KB |
Output is correct |
41 |
Correct |
406 ms |
26340 KB |
Output is correct |
42 |
Correct |
52 ms |
17004 KB |
Output is correct |
43 |
Correct |
2976 ms |
61560 KB |
Output is correct |
44 |
Correct |
2421 ms |
65872 KB |
Output is correct |
45 |
Correct |
1969 ms |
62384 KB |
Output is correct |
46 |
Correct |
1334 ms |
62444 KB |
Output is correct |
47 |
Correct |
781 ms |
46860 KB |
Output is correct |
48 |
Correct |
1412 ms |
62544 KB |
Output is correct |
49 |
Correct |
1389 ms |
62248 KB |
Output is correct |
50 |
Correct |
590 ms |
43344 KB |
Output is correct |
51 |
Correct |
17 ms |
15344 KB |
Output is correct |
52 |
Correct |
17 ms |
15344 KB |
Output is correct |
53 |
Correct |
17 ms |
15344 KB |
Output is correct |
54 |
Correct |
48 ms |
15984 KB |
Output is correct |
55 |
Correct |
49 ms |
15984 KB |
Output is correct |
56 |
Correct |
47 ms |
15984 KB |
Output is correct |
57 |
Correct |
89 ms |
24036 KB |
Output is correct |
58 |
Correct |
89 ms |
24036 KB |
Output is correct |
59 |
Correct |
94 ms |
24036 KB |
Output is correct |
60 |
Correct |
692 ms |
30308 KB |
Output is correct |
61 |
Correct |
677 ms |
30308 KB |
Output is correct |
62 |
Correct |
715 ms |
30308 KB |
Output is correct |
63 |
Correct |
892 ms |
29496 KB |
Output is correct |
64 |
Correct |
886 ms |
29556 KB |
Output is correct |
65 |
Correct |
875 ms |
29540 KB |
Output is correct |
66 |
Correct |
375 ms |
27876 KB |
Output is correct |
67 |
Correct |
370 ms |
30180 KB |
Output is correct |
68 |
Correct |
363 ms |
30180 KB |
Output is correct |
69 |
Correct |
384 ms |
30180 KB |
Output is correct |
70 |
Correct |
357 ms |
30180 KB |
Output is correct |
71 |
Correct |
370 ms |
30180 KB |
Output is correct |
72 |
Correct |
374 ms |
30140 KB |
Output is correct |
73 |
Correct |
362 ms |
30308 KB |
Output is correct |
74 |
Correct |
388 ms |
30180 KB |
Output is correct |
75 |
Correct |
286 ms |
52688 KB |
Output is correct |
76 |
Correct |
276 ms |
52344 KB |
Output is correct |
77 |
Correct |
249 ms |
52592 KB |
Output is correct |
78 |
Correct |
263 ms |
52432 KB |
Output is correct |
79 |
Correct |
576 ms |
52432 KB |
Output is correct |
80 |
Correct |
257 ms |
52304 KB |
Output is correct |
81 |
Correct |
2866 ms |
70300 KB |
Output is correct |
82 |
Correct |
2397 ms |
70244 KB |
Output is correct |
83 |
Correct |
2499 ms |
70100 KB |
Output is correct |
84 |
Correct |
2677 ms |
70560 KB |
Output is correct |
85 |
Correct |
2504 ms |
70256 KB |
Output is correct |
86 |
Correct |
2348 ms |
70256 KB |
Output is correct |
87 |
Correct |
2956 ms |
70296 KB |
Output is correct |
88 |
Execution timed out |
3063 ms |
63016 KB |
Time limit exceeded |
89 |
Halted |
0 ms |
0 KB |
- |