#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
int n, x[N], y[N], r[N];
int ans[N];
bool out[N];
unordered_map<int, int> mp;
vector<ii> vc[N];
bool ck(int i, int j){
// cout << i << " " << j << "\n";
long long dist = (1LL * ((long long)x[i] - x[j]) * ((long long)x[i] - x[j]) + 1LL * ((long long)y[i] - y[j]) * ((long long)y[i] - y[j]));
long long rd = 1LL * ((long long)r[i] + r[j]) * ((long long)r[i] + r[j]);
return (dist <= rd);
}
void process(){
cin >> n;
for(int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> r[i];
set<ii> rem;
for(int i = 1; i <= n; i++) rem.insert({-r[i], i});
bool chk = 1;
for(int i = 1; i <= n; i++) chk &= (r[i] == 1);
if(chk){
for(int i = 1; i <= n; i++) cout << i << " ";
cout << "\n";
exit(0);
}
for(int i = 30; i >= 0; i--){// executing with radius (1LL << (i - 1)) to (1LL << i)
int rad = (1LL << i);
mp.clear();
for(int j = 1; j <= n; j++) vc[j].clear();
vector<int> diff;
for(int j = 1; j <= n; j++) if(!out[j]) diff.pb(x[j] / rad);
sort(diff.begin(), diff.end());
diff.resize(unique(diff.begin(), diff.end()) - diff.begin());
for(int j = 0; j < diff.size(); j++) mp[diff[j]] = j + 1;
for(int j = 1; j <= n; j++){
if(!out[j]){
//cout << "OK " << rad << " " << j << " " << x[j]/rad << " " << y[j] << "\n";
vc[mp[x[j]/rad]].pb({y[j], j});
}
}
for(int j = 1; j <= n; j++) sort(vc[j].begin(), vc[j].end());
while(!rem.empty() && -((*rem.begin()).fi) >= (1LL << (i - 1))){
int ind = (*rem.begin()).se;
// cout << rad << " " << ind << "\n";
assert(!out[ind]);
out[ind] = 1;
ans[ind] = ind;
rem.erase({-r[ind], ind});
for(int i2 = x[ind]/rad - 3; i2 <= x[ind]/rad + 3; i2++){
if(mp.find(i2) == mp.end()) continue;
int temp = mp[i2];
long long lee = (y[ind]/rad) - 3, rii = (y[ind] / rad) + 3;
// cout <<
lee *= (long long)rad, rii *= (long long)rad;
lee = max(lee, (long long)-1e9);
rii = min(rii, (long long)1e9);
int le = lee, ri = rii;
// cout << le << " " << ri << "\n";
vector<ii>::iterator it = lower_bound(vc[temp].begin(), vc[temp].end(), make_pair(le, -oo));
for(; it != vc[temp].end(); it++){
if((*it).fi > ri) break;
if(out[(*it).se]) continue;
if(ck(ind, (*it).se)){
//cout << ind << " " << (*it).se << "\n";
ans[(*it).se] = ind;
rem.erase({-r[(*it).se], (*it).se});
out[(*it).se] = 1;
}
}
}
}
}
for(int i = 1; i <= n; i++) if(!ans[i]) ans[i] = i;
for(int i = 1; i <= n; i++) cout << ans[i] << " ";
cout << "\n";
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
process();
}
Compilation message
circle_selection.cpp:16:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
16 | const int oo = 1e18 + 7, mod = 1e9 + 7;
| ~~~~~^~~
circle_selection.cpp: In function 'void process()':
circle_selection.cpp:54:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int j = 0; j < diff.size(); j++) mp[diff[j]] = j + 1;
| ~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7380 KB |
Output is correct |
2 |
Correct |
3 ms |
7380 KB |
Output is correct |
3 |
Correct |
3 ms |
7380 KB |
Output is correct |
4 |
Correct |
3 ms |
7380 KB |
Output is correct |
5 |
Correct |
3 ms |
7380 KB |
Output is correct |
6 |
Correct |
4 ms |
7380 KB |
Output is correct |
7 |
Correct |
4 ms |
7380 KB |
Output is correct |
8 |
Correct |
3 ms |
7380 KB |
Output is correct |
9 |
Correct |
4 ms |
7348 KB |
Output is correct |
10 |
Correct |
4 ms |
7380 KB |
Output is correct |
11 |
Correct |
4 ms |
7380 KB |
Output is correct |
12 |
Correct |
4 ms |
7380 KB |
Output is correct |
13 |
Correct |
4 ms |
7380 KB |
Output is correct |
14 |
Correct |
4 ms |
7380 KB |
Output is correct |
15 |
Correct |
4 ms |
7380 KB |
Output is correct |
16 |
Correct |
5 ms |
7380 KB |
Output is correct |
17 |
Correct |
5 ms |
7380 KB |
Output is correct |
18 |
Correct |
5 ms |
7380 KB |
Output is correct |
19 |
Correct |
8 ms |
7892 KB |
Output is correct |
20 |
Correct |
8 ms |
7892 KB |
Output is correct |
21 |
Correct |
8 ms |
7764 KB |
Output is correct |
22 |
Correct |
19 ms |
8292 KB |
Output is correct |
23 |
Correct |
20 ms |
8044 KB |
Output is correct |
24 |
Correct |
20 ms |
8276 KB |
Output is correct |
25 |
Correct |
22 ms |
8356 KB |
Output is correct |
26 |
Correct |
20 ms |
8356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
440 ms |
31976 KB |
Output is correct |
2 |
Correct |
479 ms |
36656 KB |
Output is correct |
3 |
Correct |
475 ms |
36808 KB |
Output is correct |
4 |
Correct |
401 ms |
30972 KB |
Output is correct |
5 |
Correct |
1107 ms |
50100 KB |
Output is correct |
6 |
Correct |
1439 ms |
69936 KB |
Output is correct |
7 |
Correct |
1088 ms |
53416 KB |
Output is correct |
8 |
Correct |
1211 ms |
62036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7380 KB |
Output is correct |
2 |
Correct |
357 ms |
22160 KB |
Output is correct |
3 |
Correct |
1350 ms |
59352 KB |
Output is correct |
4 |
Correct |
1367 ms |
59544 KB |
Output is correct |
5 |
Correct |
1221 ms |
52784 KB |
Output is correct |
6 |
Correct |
533 ms |
32060 KB |
Output is correct |
7 |
Correct |
292 ms |
20512 KB |
Output is correct |
8 |
Correct |
58 ms |
10424 KB |
Output is correct |
9 |
Correct |
1430 ms |
59300 KB |
Output is correct |
10 |
Correct |
1191 ms |
50208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1331 ms |
59912 KB |
Output is correct |
2 |
Correct |
155 ms |
26836 KB |
Output is correct |
3 |
Correct |
849 ms |
42308 KB |
Output is correct |
4 |
Correct |
1959 ms |
73532 KB |
Output is correct |
5 |
Correct |
1979 ms |
81812 KB |
Output is correct |
6 |
Correct |
792 ms |
42840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7380 KB |
Output is correct |
2 |
Correct |
3 ms |
7380 KB |
Output is correct |
3 |
Correct |
3 ms |
7380 KB |
Output is correct |
4 |
Correct |
3 ms |
7380 KB |
Output is correct |
5 |
Correct |
3 ms |
7380 KB |
Output is correct |
6 |
Correct |
4 ms |
7380 KB |
Output is correct |
7 |
Correct |
4 ms |
7380 KB |
Output is correct |
8 |
Correct |
3 ms |
7380 KB |
Output is correct |
9 |
Correct |
4 ms |
7348 KB |
Output is correct |
10 |
Correct |
4 ms |
7380 KB |
Output is correct |
11 |
Correct |
4 ms |
7380 KB |
Output is correct |
12 |
Correct |
4 ms |
7380 KB |
Output is correct |
13 |
Correct |
4 ms |
7380 KB |
Output is correct |
14 |
Correct |
4 ms |
7380 KB |
Output is correct |
15 |
Correct |
4 ms |
7380 KB |
Output is correct |
16 |
Correct |
5 ms |
7380 KB |
Output is correct |
17 |
Correct |
5 ms |
7380 KB |
Output is correct |
18 |
Correct |
5 ms |
7380 KB |
Output is correct |
19 |
Correct |
8 ms |
7892 KB |
Output is correct |
20 |
Correct |
8 ms |
7892 KB |
Output is correct |
21 |
Correct |
8 ms |
7764 KB |
Output is correct |
22 |
Correct |
19 ms |
8292 KB |
Output is correct |
23 |
Correct |
20 ms |
8044 KB |
Output is correct |
24 |
Correct |
20 ms |
8276 KB |
Output is correct |
25 |
Correct |
22 ms |
8356 KB |
Output is correct |
26 |
Correct |
20 ms |
8356 KB |
Output is correct |
27 |
Correct |
14 ms |
8276 KB |
Output is correct |
28 |
Correct |
15 ms |
8328 KB |
Output is correct |
29 |
Correct |
14 ms |
8316 KB |
Output is correct |
30 |
Correct |
35 ms |
8772 KB |
Output is correct |
31 |
Correct |
35 ms |
9352 KB |
Output is correct |
32 |
Correct |
36 ms |
9208 KB |
Output is correct |
33 |
Correct |
114 ms |
15248 KB |
Output is correct |
34 |
Correct |
118 ms |
15260 KB |
Output is correct |
35 |
Correct |
160 ms |
17040 KB |
Output is correct |
36 |
Correct |
398 ms |
25992 KB |
Output is correct |
37 |
Correct |
398 ms |
25384 KB |
Output is correct |
38 |
Correct |
377 ms |
24104 KB |
Output is correct |
39 |
Correct |
557 ms |
20496 KB |
Output is correct |
40 |
Correct |
554 ms |
20616 KB |
Output is correct |
41 |
Correct |
560 ms |
20516 KB |
Output is correct |
42 |
Correct |
408 ms |
19584 KB |
Output is correct |
43 |
Correct |
526 ms |
31768 KB |
Output is correct |
44 |
Correct |
522 ms |
31636 KB |
Output is correct |
45 |
Correct |
542 ms |
31692 KB |
Output is correct |
46 |
Correct |
557 ms |
31824 KB |
Output is correct |
47 |
Correct |
536 ms |
31956 KB |
Output is correct |
48 |
Correct |
566 ms |
31720 KB |
Output is correct |
49 |
Correct |
530 ms |
31696 KB |
Output is correct |
50 |
Correct |
511 ms |
31804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7380 KB |
Output is correct |
2 |
Correct |
3 ms |
7380 KB |
Output is correct |
3 |
Correct |
3 ms |
7380 KB |
Output is correct |
4 |
Correct |
3 ms |
7380 KB |
Output is correct |
5 |
Correct |
3 ms |
7380 KB |
Output is correct |
6 |
Correct |
4 ms |
7380 KB |
Output is correct |
7 |
Correct |
4 ms |
7380 KB |
Output is correct |
8 |
Correct |
3 ms |
7380 KB |
Output is correct |
9 |
Correct |
4 ms |
7348 KB |
Output is correct |
10 |
Correct |
4 ms |
7380 KB |
Output is correct |
11 |
Correct |
4 ms |
7380 KB |
Output is correct |
12 |
Correct |
4 ms |
7380 KB |
Output is correct |
13 |
Correct |
4 ms |
7380 KB |
Output is correct |
14 |
Correct |
4 ms |
7380 KB |
Output is correct |
15 |
Correct |
4 ms |
7380 KB |
Output is correct |
16 |
Correct |
5 ms |
7380 KB |
Output is correct |
17 |
Correct |
5 ms |
7380 KB |
Output is correct |
18 |
Correct |
5 ms |
7380 KB |
Output is correct |
19 |
Correct |
8 ms |
7892 KB |
Output is correct |
20 |
Correct |
8 ms |
7892 KB |
Output is correct |
21 |
Correct |
8 ms |
7764 KB |
Output is correct |
22 |
Correct |
19 ms |
8292 KB |
Output is correct |
23 |
Correct |
20 ms |
8044 KB |
Output is correct |
24 |
Correct |
20 ms |
8276 KB |
Output is correct |
25 |
Correct |
22 ms |
8356 KB |
Output is correct |
26 |
Correct |
20 ms |
8356 KB |
Output is correct |
27 |
Correct |
440 ms |
31976 KB |
Output is correct |
28 |
Correct |
479 ms |
36656 KB |
Output is correct |
29 |
Correct |
475 ms |
36808 KB |
Output is correct |
30 |
Correct |
401 ms |
30972 KB |
Output is correct |
31 |
Correct |
1107 ms |
50100 KB |
Output is correct |
32 |
Correct |
1439 ms |
69936 KB |
Output is correct |
33 |
Correct |
1088 ms |
53416 KB |
Output is correct |
34 |
Correct |
1211 ms |
62036 KB |
Output is correct |
35 |
Correct |
3 ms |
7380 KB |
Output is correct |
36 |
Correct |
357 ms |
22160 KB |
Output is correct |
37 |
Correct |
1350 ms |
59352 KB |
Output is correct |
38 |
Correct |
1367 ms |
59544 KB |
Output is correct |
39 |
Correct |
1221 ms |
52784 KB |
Output is correct |
40 |
Correct |
533 ms |
32060 KB |
Output is correct |
41 |
Correct |
292 ms |
20512 KB |
Output is correct |
42 |
Correct |
58 ms |
10424 KB |
Output is correct |
43 |
Correct |
1430 ms |
59300 KB |
Output is correct |
44 |
Correct |
1191 ms |
50208 KB |
Output is correct |
45 |
Correct |
1331 ms |
59912 KB |
Output is correct |
46 |
Correct |
155 ms |
26836 KB |
Output is correct |
47 |
Correct |
849 ms |
42308 KB |
Output is correct |
48 |
Correct |
1959 ms |
73532 KB |
Output is correct |
49 |
Correct |
1979 ms |
81812 KB |
Output is correct |
50 |
Correct |
792 ms |
42840 KB |
Output is correct |
51 |
Correct |
14 ms |
8276 KB |
Output is correct |
52 |
Correct |
15 ms |
8328 KB |
Output is correct |
53 |
Correct |
14 ms |
8316 KB |
Output is correct |
54 |
Correct |
35 ms |
8772 KB |
Output is correct |
55 |
Correct |
35 ms |
9352 KB |
Output is correct |
56 |
Correct |
36 ms |
9208 KB |
Output is correct |
57 |
Correct |
114 ms |
15248 KB |
Output is correct |
58 |
Correct |
118 ms |
15260 KB |
Output is correct |
59 |
Correct |
160 ms |
17040 KB |
Output is correct |
60 |
Correct |
398 ms |
25992 KB |
Output is correct |
61 |
Correct |
398 ms |
25384 KB |
Output is correct |
62 |
Correct |
377 ms |
24104 KB |
Output is correct |
63 |
Correct |
557 ms |
20496 KB |
Output is correct |
64 |
Correct |
554 ms |
20616 KB |
Output is correct |
65 |
Correct |
560 ms |
20516 KB |
Output is correct |
66 |
Correct |
408 ms |
19584 KB |
Output is correct |
67 |
Correct |
526 ms |
31768 KB |
Output is correct |
68 |
Correct |
522 ms |
31636 KB |
Output is correct |
69 |
Correct |
542 ms |
31692 KB |
Output is correct |
70 |
Correct |
557 ms |
31824 KB |
Output is correct |
71 |
Correct |
536 ms |
31956 KB |
Output is correct |
72 |
Correct |
566 ms |
31720 KB |
Output is correct |
73 |
Correct |
530 ms |
31696 KB |
Output is correct |
74 |
Correct |
511 ms |
31804 KB |
Output is correct |
75 |
Correct |
587 ms |
34788 KB |
Output is correct |
76 |
Correct |
679 ms |
36172 KB |
Output is correct |
77 |
Correct |
610 ms |
31996 KB |
Output is correct |
78 |
Correct |
537 ms |
30804 KB |
Output is correct |
79 |
Correct |
756 ms |
36100 KB |
Output is correct |
80 |
Correct |
578 ms |
30708 KB |
Output is correct |
81 |
Correct |
1574 ms |
61100 KB |
Output is correct |
82 |
Correct |
1454 ms |
57612 KB |
Output is correct |
83 |
Correct |
1486 ms |
64232 KB |
Output is correct |
84 |
Correct |
1420 ms |
59332 KB |
Output is correct |
85 |
Correct |
1502 ms |
59800 KB |
Output is correct |
86 |
Correct |
1453 ms |
59160 KB |
Output is correct |
87 |
Correct |
1312 ms |
47900 KB |
Output is correct |
88 |
Correct |
1934 ms |
50300 KB |
Output is correct |
89 |
Correct |
1961 ms |
50060 KB |
Output is correct |
90 |
Correct |
1937 ms |
49812 KB |
Output is correct |
91 |
Correct |
1946 ms |
49864 KB |
Output is correct |
92 |
Correct |
1966 ms |
49820 KB |
Output is correct |
93 |
Correct |
2529 ms |
81632 KB |
Output is correct |
94 |
Correct |
1525 ms |
33024 KB |
Output is correct |
95 |
Correct |
2545 ms |
81900 KB |
Output is correct |
96 |
Correct |
2456 ms |
80788 KB |
Output is correct |
97 |
Correct |
1669 ms |
41136 KB |
Output is correct |
98 |
Correct |
1747 ms |
64812 KB |
Output is correct |
99 |
Correct |
2726 ms |
81648 KB |
Output is correct |
100 |
Execution timed out |
3073 ms |
75752 KB |
Time limit exceeded |
101 |
Halted |
0 ms |
0 KB |
- |