#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define pb emplace_back
#define F first
#define S second
#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
#define f2(x) ((x)*(x))
const int maxn=3e5+9,inf=1ll<<60,bl=2e9+3;
struct C{int x,y,r,id;}a[maxn];
int n,res[maxn];
bitset<maxn>rmv;
unordered_map<int,VI>mp;
main(){
IOS;
cin>>n;
REP(i,0,n)cin>>a[i].x>>a[i].y>>a[i].r,a[i].id=i;
sort(a,a+n,[](C x,C y){return x.r==y.r?x.id<y.id:x.r>y.r;});
int k=1ll<<30;
REP(i,0,n){
if(rmv[i])continue;
while(a[i].r<(k>>1)){
k>>=1;
mp.clear();
REP(j,i,n)if(!rmv[j])mp[a[j].x/k*bl+a[j].y/k].pb(j);
}
int xx=a[i].x/k,yy=a[i].y/k;
REP(x,xx-2,xx+3)REP(y,yy-2,yy+3){
auto&tls=mp[x*bl+y];
for(auto it=tls.begin();it!=tls.end();++it){
if(rmv[*it])continue;
C c=a[*it];
if(f2(a[i].x-c.x)+f2(a[i].y-c.y)<=f2(a[i].r+c.r)){
res[c.id]=a[i].id;
rmv[*it]=1;
}
}
}
}
REP(i,0,n)cout<<res[i]+1<<" ";
}
Compilation message
circle_selection.cpp:20:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
14620 KB |
Output is correct |
2 |
Correct |
279 ms |
18480 KB |
Output is correct |
3 |
Correct |
252 ms |
17936 KB |
Output is correct |
4 |
Incorrect |
265 ms |
14360 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1839 ms |
71168 KB |
Output is correct |
3 |
Execution timed out |
3020 ms |
151396 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3012 ms |
61052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |