#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)
using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;
//Note to self: Check for overflow
map<pii,set<pair<pii,pii>>> koji;
int ans[300005];
int main()
{
FAST;
int R=2e9+1;
set<pair<pii,pii>> krugovi;
int n; cin>>n;
ff(i,0,n)
{
int x,y,r; cin>>x>>y>>r;
krugovi.insert({{r,-i},{x,y}});
koji[{(x+1e9)/R,(y+1e9)/R}].insert({{r,-i},{x,y}});
}
while (!krugovi.empty())
{
auto it=*prev(krugovi.end());
int r=it.xx.xx,i=-it.xx.yy,x=it.yy.xx,y=it.yy.yy;
while (2*r<R)
{
R=(R+1)/2;
koji.clear();
for (auto jt : krugovi)
{
int x1=jt.yy.xx,y1=jt.yy.yy;
koji[{(x1+1e9)/R,(y1+1e9)/R}].insert(jt);
}
}
vector<pair<pii,pii>> to_delete;
fff(dx,-2,2) fff(dy,-2,2) for (auto jt : koji[{(x+1e9)/R+dx,(y+1e9)/R+dy}])
{
int r1=jt.xx.xx,i1=-jt.xx.yy,x1=jt.yy.xx,y1=jt.yy.yy;
if ((li)(r+r1)*(r+r1) >= (li)(x-x1)*(x-x1) + (li)(y-y1)*(y-y1)) ans[i1]=i,to_delete.pb({{r1,-i1},{x1,y1}});
}
for (auto jt : to_delete)
{
krugovi.erase(jt);
int x1=jt.yy.xx,y1=jt.yy.yy;
koji[{(x1+1e9)/R,(y1+1e9)/R}].erase(jt);
}
}
ff(i,0,n) cout<<ans[i]+1<<" ";
}
//Note to self: Check for overflow
/*
3
1 1 1
2 2 2
3 3 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
324 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
456 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
472 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
1364 KB |
Output is correct |
20 |
Correct |
6 ms |
1268 KB |
Output is correct |
21 |
Correct |
6 ms |
1364 KB |
Output is correct |
22 |
Correct |
52 ms |
6488 KB |
Output is correct |
23 |
Correct |
53 ms |
5836 KB |
Output is correct |
24 |
Correct |
54 ms |
5456 KB |
Output is correct |
25 |
Correct |
52 ms |
6348 KB |
Output is correct |
26 |
Correct |
56 ms |
5840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
845 ms |
47384 KB |
Output is correct |
2 |
Correct |
898 ms |
52276 KB |
Output is correct |
3 |
Correct |
1002 ms |
49912 KB |
Output is correct |
4 |
Correct |
790 ms |
62272 KB |
Output is correct |
5 |
Execution timed out |
3055 ms |
42792 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2120 ms |
101828 KB |
Output is correct |
3 |
Execution timed out |
3060 ms |
70532 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3042 ms |
62620 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
324 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
456 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
472 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
1364 KB |
Output is correct |
20 |
Correct |
6 ms |
1268 KB |
Output is correct |
21 |
Correct |
6 ms |
1364 KB |
Output is correct |
22 |
Correct |
52 ms |
6488 KB |
Output is correct |
23 |
Correct |
53 ms |
5836 KB |
Output is correct |
24 |
Correct |
54 ms |
5456 KB |
Output is correct |
25 |
Correct |
52 ms |
6348 KB |
Output is correct |
26 |
Correct |
56 ms |
5840 KB |
Output is correct |
27 |
Correct |
14 ms |
2260 KB |
Output is correct |
28 |
Correct |
14 ms |
2224 KB |
Output is correct |
29 |
Correct |
13 ms |
2256 KB |
Output is correct |
30 |
Correct |
125 ms |
13272 KB |
Output is correct |
31 |
Correct |
122 ms |
12188 KB |
Output is correct |
32 |
Correct |
120 ms |
11260 KB |
Output is correct |
33 |
Correct |
179 ms |
20536 KB |
Output is correct |
34 |
Correct |
182 ms |
20500 KB |
Output is correct |
35 |
Correct |
272 ms |
18416 KB |
Output is correct |
36 |
Correct |
2437 ms |
110712 KB |
Output is correct |
37 |
Correct |
2414 ms |
97220 KB |
Output is correct |
38 |
Correct |
2271 ms |
112460 KB |
Output is correct |
39 |
Correct |
2210 ms |
21284 KB |
Output is correct |
40 |
Correct |
2196 ms |
21236 KB |
Output is correct |
41 |
Correct |
2200 ms |
21120 KB |
Output is correct |
42 |
Correct |
984 ms |
21992 KB |
Output is correct |
43 |
Correct |
1947 ms |
192444 KB |
Output is correct |
44 |
Correct |
1987 ms |
192916 KB |
Output is correct |
45 |
Correct |
2029 ms |
192604 KB |
Output is correct |
46 |
Correct |
2048 ms |
192972 KB |
Output is correct |
47 |
Correct |
2049 ms |
193000 KB |
Output is correct |
48 |
Correct |
1988 ms |
192960 KB |
Output is correct |
49 |
Correct |
2044 ms |
192988 KB |
Output is correct |
50 |
Correct |
2089 ms |
192884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
324 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
456 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
472 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
1364 KB |
Output is correct |
20 |
Correct |
6 ms |
1268 KB |
Output is correct |
21 |
Correct |
6 ms |
1364 KB |
Output is correct |
22 |
Correct |
52 ms |
6488 KB |
Output is correct |
23 |
Correct |
53 ms |
5836 KB |
Output is correct |
24 |
Correct |
54 ms |
5456 KB |
Output is correct |
25 |
Correct |
52 ms |
6348 KB |
Output is correct |
26 |
Correct |
56 ms |
5840 KB |
Output is correct |
27 |
Correct |
845 ms |
47384 KB |
Output is correct |
28 |
Correct |
898 ms |
52276 KB |
Output is correct |
29 |
Correct |
1002 ms |
49912 KB |
Output is correct |
30 |
Correct |
790 ms |
62272 KB |
Output is correct |
31 |
Execution timed out |
3055 ms |
42792 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |