// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- insert(x),erase(x)
- find_by_order(k): return iterator to the k-th smallest element
- order_of_key(x): the number of elements that are strictly smaller
*/
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define int long long
#define ld long double
#define pii pair<int,int>
#define piii pair<int,pii>
#define mpp make_pair
#define fi first
#define se second
const long long inf=1e18;
const int mod=998244353;
const int maxn=300005;
const int maxs=655;
const int maxm=200005;
const int maxq=1000005;
const int maxl=25;
const int maxa=1000000;
const int root=3;
int power(int a,int n){
int res=1;
while(n){
if(n&1) res=res*a%mod;
a=a*a%mod;n>>=1;
}
return res;
}
const int iroot=power(3,mod-2);
const int base=101;
int n,x[maxn],y[maxn],r[maxn],res[maxn],B;
map<pii,vector<int>> mp;
set<int> cc;
void build(){
mp.clear();
for(int i:cc) mp[{x[i]/B,y[i]/B}].push_back(i);
}
bool intersect(int i,int j){
return (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<=(r[i]+r[j])*(r[i]+r[j]);
}
void solve(){
cin >> n;
for(int i=1;i<=n;i++){
cin >> x[i] >> y[i] >> r[i];
cc.insert(i);
}
vector<int> ord(n);
iota(ord.begin(),ord.end(),1);
sort(ord.begin(),ord.end(),[&](int a,int b){
if(r[a]==r[b]) return a<b;
return r[a]>r[b];
});
for(int i:ord){
if(res[i]) continue;
if(!B || r[i]*2<=B){
B=r[i];
build();
}
for(int X=x[i]/B-2;X<=x[i]/B+2;X++) for(int Y=y[i]/B-2;Y<=y[i]/B+2;Y++){
auto it=mp.find({X,Y});
if(it!=mp.end()){
for(int j:it->se) if(!res[j] && intersect(i,j)){
res[j]=i;
cc.erase(j);
}
}
}
}
for(int i=1;i<=n;i++) cout << res[i] << ' ';
cout << '\n';
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
int test=1;//cin >> test;
while(test--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
2 ms |
6492 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
4 ms |
7004 KB |
Output is correct |
20 |
Correct |
4 ms |
7004 KB |
Output is correct |
21 |
Correct |
4 ms |
7004 KB |
Output is correct |
22 |
Correct |
12 ms |
7268 KB |
Output is correct |
23 |
Correct |
16 ms |
7272 KB |
Output is correct |
24 |
Correct |
12 ms |
7484 KB |
Output is correct |
25 |
Correct |
12 ms |
7260 KB |
Output is correct |
26 |
Correct |
12 ms |
7512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
192 ms |
30100 KB |
Output is correct |
2 |
Correct |
216 ms |
30376 KB |
Output is correct |
3 |
Correct |
200 ms |
30804 KB |
Output is correct |
4 |
Correct |
204 ms |
30408 KB |
Output is correct |
5 |
Correct |
378 ms |
32748 KB |
Output is correct |
6 |
Correct |
813 ms |
49668 KB |
Output is correct |
7 |
Correct |
418 ms |
39116 KB |
Output is correct |
8 |
Correct |
481 ms |
41188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
422 ms |
24344 KB |
Output is correct |
3 |
Correct |
1836 ms |
60940 KB |
Output is correct |
4 |
Correct |
1822 ms |
61116 KB |
Output is correct |
5 |
Correct |
1749 ms |
54472 KB |
Output is correct |
6 |
Correct |
577 ms |
34132 KB |
Output is correct |
7 |
Correct |
232 ms |
21328 KB |
Output is correct |
8 |
Correct |
33 ms |
9560 KB |
Output is correct |
9 |
Correct |
2123 ms |
68168 KB |
Output is correct |
10 |
Correct |
1624 ms |
61320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1391 ms |
60956 KB |
Output is correct |
2 |
Correct |
954 ms |
68180 KB |
Output is correct |
3 |
Correct |
537 ms |
47956 KB |
Output is correct |
4 |
Correct |
998 ms |
68588 KB |
Output is correct |
5 |
Correct |
936 ms |
68748 KB |
Output is correct |
6 |
Correct |
412 ms |
42076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
2 ms |
6492 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
4 ms |
7004 KB |
Output is correct |
20 |
Correct |
4 ms |
7004 KB |
Output is correct |
21 |
Correct |
4 ms |
7004 KB |
Output is correct |
22 |
Correct |
12 ms |
7268 KB |
Output is correct |
23 |
Correct |
16 ms |
7272 KB |
Output is correct |
24 |
Correct |
12 ms |
7484 KB |
Output is correct |
25 |
Correct |
12 ms |
7260 KB |
Output is correct |
26 |
Correct |
12 ms |
7512 KB |
Output is correct |
27 |
Correct |
7 ms |
7260 KB |
Output is correct |
28 |
Correct |
7 ms |
7260 KB |
Output is correct |
29 |
Correct |
7 ms |
7256 KB |
Output is correct |
30 |
Correct |
28 ms |
8344 KB |
Output is correct |
31 |
Correct |
28 ms |
8440 KB |
Output is correct |
32 |
Correct |
28 ms |
8284 KB |
Output is correct |
33 |
Correct |
62 ms |
14196 KB |
Output is correct |
34 |
Correct |
64 ms |
14536 KB |
Output is correct |
35 |
Correct |
72 ms |
13800 KB |
Output is correct |
36 |
Correct |
367 ms |
24380 KB |
Output is correct |
37 |
Correct |
393 ms |
24372 KB |
Output is correct |
38 |
Correct |
373 ms |
24400 KB |
Output is correct |
39 |
Correct |
287 ms |
22992 KB |
Output is correct |
40 |
Correct |
269 ms |
23732 KB |
Output is correct |
41 |
Correct |
328 ms |
23876 KB |
Output is correct |
42 |
Correct |
214 ms |
25740 KB |
Output is correct |
43 |
Correct |
241 ms |
26708 KB |
Output is correct |
44 |
Correct |
262 ms |
26724 KB |
Output is correct |
45 |
Correct |
266 ms |
26704 KB |
Output is correct |
46 |
Correct |
246 ms |
26712 KB |
Output is correct |
47 |
Correct |
233 ms |
26608 KB |
Output is correct |
48 |
Correct |
237 ms |
26700 KB |
Output is correct |
49 |
Correct |
283 ms |
26552 KB |
Output is correct |
50 |
Correct |
236 ms |
26688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6492 KB |
Output is correct |
17 |
Correct |
2 ms |
6492 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
4 ms |
7004 KB |
Output is correct |
20 |
Correct |
4 ms |
7004 KB |
Output is correct |
21 |
Correct |
4 ms |
7004 KB |
Output is correct |
22 |
Correct |
12 ms |
7268 KB |
Output is correct |
23 |
Correct |
16 ms |
7272 KB |
Output is correct |
24 |
Correct |
12 ms |
7484 KB |
Output is correct |
25 |
Correct |
12 ms |
7260 KB |
Output is correct |
26 |
Correct |
12 ms |
7512 KB |
Output is correct |
27 |
Correct |
192 ms |
30100 KB |
Output is correct |
28 |
Correct |
216 ms |
30376 KB |
Output is correct |
29 |
Correct |
200 ms |
30804 KB |
Output is correct |
30 |
Correct |
204 ms |
30408 KB |
Output is correct |
31 |
Correct |
378 ms |
32748 KB |
Output is correct |
32 |
Correct |
813 ms |
49668 KB |
Output is correct |
33 |
Correct |
418 ms |
39116 KB |
Output is correct |
34 |
Correct |
481 ms |
41188 KB |
Output is correct |
35 |
Correct |
1 ms |
6492 KB |
Output is correct |
36 |
Correct |
422 ms |
24344 KB |
Output is correct |
37 |
Correct |
1836 ms |
60940 KB |
Output is correct |
38 |
Correct |
1822 ms |
61116 KB |
Output is correct |
39 |
Correct |
1749 ms |
54472 KB |
Output is correct |
40 |
Correct |
577 ms |
34132 KB |
Output is correct |
41 |
Correct |
232 ms |
21328 KB |
Output is correct |
42 |
Correct |
33 ms |
9560 KB |
Output is correct |
43 |
Correct |
2123 ms |
68168 KB |
Output is correct |
44 |
Correct |
1624 ms |
61320 KB |
Output is correct |
45 |
Correct |
1391 ms |
60956 KB |
Output is correct |
46 |
Correct |
954 ms |
68180 KB |
Output is correct |
47 |
Correct |
537 ms |
47956 KB |
Output is correct |
48 |
Correct |
998 ms |
68588 KB |
Output is correct |
49 |
Correct |
936 ms |
68748 KB |
Output is correct |
50 |
Correct |
412 ms |
42076 KB |
Output is correct |
51 |
Correct |
7 ms |
7260 KB |
Output is correct |
52 |
Correct |
7 ms |
7260 KB |
Output is correct |
53 |
Correct |
7 ms |
7256 KB |
Output is correct |
54 |
Correct |
28 ms |
8344 KB |
Output is correct |
55 |
Correct |
28 ms |
8440 KB |
Output is correct |
56 |
Correct |
28 ms |
8284 KB |
Output is correct |
57 |
Correct |
62 ms |
14196 KB |
Output is correct |
58 |
Correct |
64 ms |
14536 KB |
Output is correct |
59 |
Correct |
72 ms |
13800 KB |
Output is correct |
60 |
Correct |
367 ms |
24380 KB |
Output is correct |
61 |
Correct |
393 ms |
24372 KB |
Output is correct |
62 |
Correct |
373 ms |
24400 KB |
Output is correct |
63 |
Correct |
287 ms |
22992 KB |
Output is correct |
64 |
Correct |
269 ms |
23732 KB |
Output is correct |
65 |
Correct |
328 ms |
23876 KB |
Output is correct |
66 |
Correct |
214 ms |
25740 KB |
Output is correct |
67 |
Correct |
241 ms |
26708 KB |
Output is correct |
68 |
Correct |
262 ms |
26724 KB |
Output is correct |
69 |
Correct |
266 ms |
26704 KB |
Output is correct |
70 |
Correct |
246 ms |
26712 KB |
Output is correct |
71 |
Correct |
233 ms |
26608 KB |
Output is correct |
72 |
Correct |
237 ms |
26700 KB |
Output is correct |
73 |
Correct |
283 ms |
26552 KB |
Output is correct |
74 |
Correct |
236 ms |
26688 KB |
Output is correct |
75 |
Correct |
247 ms |
38804 KB |
Output is correct |
76 |
Correct |
239 ms |
37948 KB |
Output is correct |
77 |
Correct |
211 ms |
39592 KB |
Output is correct |
78 |
Correct |
218 ms |
39872 KB |
Output is correct |
79 |
Correct |
346 ms |
38736 KB |
Output is correct |
80 |
Correct |
204 ms |
39340 KB |
Output is correct |
81 |
Correct |
1914 ms |
69200 KB |
Output is correct |
82 |
Correct |
1821 ms |
68964 KB |
Output is correct |
83 |
Correct |
1748 ms |
68772 KB |
Output is correct |
84 |
Correct |
2045 ms |
69464 KB |
Output is correct |
85 |
Correct |
1879 ms |
68892 KB |
Output is correct |
86 |
Correct |
1807 ms |
68928 KB |
Output is correct |
87 |
Correct |
2122 ms |
68892 KB |
Output is correct |
88 |
Correct |
1321 ms |
59892 KB |
Output is correct |
89 |
Correct |
1283 ms |
59672 KB |
Output is correct |
90 |
Correct |
1372 ms |
59676 KB |
Output is correct |
91 |
Correct |
1356 ms |
59692 KB |
Output is correct |
92 |
Correct |
1345 ms |
59644 KB |
Output is correct |
93 |
Correct |
1221 ms |
67876 KB |
Output is correct |
94 |
Correct |
1381 ms |
68180 KB |
Output is correct |
95 |
Correct |
1249 ms |
67956 KB |
Output is correct |
96 |
Correct |
1365 ms |
67872 KB |
Output is correct |
97 |
Correct |
1774 ms |
67804 KB |
Output is correct |
98 |
Correct |
939 ms |
56584 KB |
Output is correct |
99 |
Correct |
1440 ms |
68040 KB |
Output is correct |
100 |
Correct |
1109 ms |
68004 KB |
Output is correct |
101 |
Correct |
1228 ms |
61384 KB |
Output is correct |
102 |
Correct |
1321 ms |
67444 KB |
Output is correct |
103 |
Correct |
1802 ms |
67492 KB |
Output is correct |
104 |
Correct |
1334 ms |
67844 KB |
Output is correct |
105 |
Correct |
1094 ms |
65544 KB |
Output is correct |
106 |
Correct |
927 ms |
66640 KB |
Output is correct |
107 |
Correct |
993 ms |
66896 KB |
Output is correct |
108 |
Correct |
924 ms |
66640 KB |
Output is correct |
109 |
Correct |
1002 ms |
66640 KB |
Output is correct |
110 |
Correct |
965 ms |
66660 KB |
Output is correct |
111 |
Correct |
942 ms |
66820 KB |
Output is correct |
112 |
Correct |
926 ms |
66612 KB |
Output is correct |
113 |
Correct |
965 ms |
66900 KB |
Output is correct |
114 |
Correct |
939 ms |
66836 KB |
Output is correct |
115 |
Correct |
941 ms |
66768 KB |
Output is correct |
116 |
Correct |
880 ms |
66616 KB |
Output is correct |