#pragma GCC optimize("O3")
#include<stdint.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define VIS(it,con) for(auto it=con.begin();it!=con.end();++it)
#define pob pop_back
#define pf push_front
#define pof pop_front
#define MIN(x,y) (x=min(x,(y)))
#define MAX(x,y) (x=max(x,(y)))
#define mid (l+r>>1)
#define lch (idx*2+1)
#define rch (idx*2+2)
/*****************************************************************************/
#include<bits/stdc++.h>
#define int int_fast64_t
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define F first
#define S second
#define endl '\n'
// #define __debug
#ifdef __debug
#define IOS (void)0
#define de(...) cerr<<__VA_ARGS__
#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
#else
#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
#define de(...) (void)0
#define ar(...) (void)0
#endif
/***********************************default***********************************/
const int maxn=3e5+9,inf=1ll<<60;
struct C{int x,y,r,id;}a[maxn];
int n,rmv[maxn],res[maxn];
map<pii,set<int>>mp;
int f2(int x){
return x*x;
}
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;});
MST(rmv,0);
int k=inf;
REP(i,0,n){
if(rmv[i])continue;
if(2*a[i].r<k){
k=a[i].r;
mp.clear();
REP(j,0,n){
if(!rmv[j]){
mp[pii(a[j].x/k,a[j].y/k)].insert(j);
}
}
}
REP(x,a[i].x/k-2,a[i].x/k+5)REP(y,a[i].y/k-2,a[i].y/k+5){
for(auto it=mp[pii(x,y)].begin();it!=mp[pii(x,y)].end();){
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;
mp[pii(x,y)].erase(it++);
}else ++it;
}
}
}
// cout<<rmv[7]<<endl; //
REP(i,0,n)cout<<res[i]+1<<" ";
}
Compilation message
circle_selection.cpp:51:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
5 ms |
2688 KB |
Output is correct |
3 |
Correct |
4 ms |
2732 KB |
Output is correct |
4 |
Correct |
4 ms |
2816 KB |
Output is correct |
5 |
Correct |
4 ms |
2688 KB |
Output is correct |
6 |
Correct |
4 ms |
2688 KB |
Output is correct |
7 |
Correct |
4 ms |
2688 KB |
Output is correct |
8 |
Correct |
5 ms |
2688 KB |
Output is correct |
9 |
Correct |
4 ms |
2688 KB |
Output is correct |
10 |
Correct |
6 ms |
2688 KB |
Output is correct |
11 |
Correct |
6 ms |
2984 KB |
Output is correct |
12 |
Correct |
6 ms |
3072 KB |
Output is correct |
13 |
Correct |
4 ms |
2944 KB |
Output is correct |
14 |
Correct |
6 ms |
3072 KB |
Output is correct |
15 |
Correct |
6 ms |
2944 KB |
Output is correct |
16 |
Correct |
5 ms |
2816 KB |
Output is correct |
17 |
Correct |
6 ms |
2816 KB |
Output is correct |
18 |
Correct |
14 ms |
2816 KB |
Output is correct |
19 |
Correct |
10 ms |
3328 KB |
Output is correct |
20 |
Correct |
11 ms |
3328 KB |
Output is correct |
21 |
Correct |
10 ms |
3328 KB |
Output is correct |
22 |
Correct |
105 ms |
16988 KB |
Output is correct |
23 |
Correct |
152 ms |
16892 KB |
Output is correct |
24 |
Correct |
126 ms |
17144 KB |
Output is correct |
25 |
Correct |
119 ms |
17204 KB |
Output is correct |
26 |
Correct |
117 ms |
17192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
323 ms |
37284 KB |
Output is correct |
2 |
Correct |
351 ms |
37244 KB |
Output is correct |
3 |
Correct |
295 ms |
37112 KB |
Output is correct |
4 |
Correct |
263 ms |
37368 KB |
Output is correct |
5 |
Correct |
691 ms |
37752 KB |
Output is correct |
6 |
Correct |
2797 ms |
170836 KB |
Output is correct |
7 |
Correct |
1029 ms |
44100 KB |
Output is correct |
8 |
Correct |
1354 ms |
62968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2688 KB |
Output is correct |
2 |
Execution timed out |
3065 ms |
279296 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3058 ms |
515072 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
5 ms |
2688 KB |
Output is correct |
3 |
Correct |
4 ms |
2732 KB |
Output is correct |
4 |
Correct |
4 ms |
2816 KB |
Output is correct |
5 |
Correct |
4 ms |
2688 KB |
Output is correct |
6 |
Correct |
4 ms |
2688 KB |
Output is correct |
7 |
Correct |
4 ms |
2688 KB |
Output is correct |
8 |
Correct |
5 ms |
2688 KB |
Output is correct |
9 |
Correct |
4 ms |
2688 KB |
Output is correct |
10 |
Correct |
6 ms |
2688 KB |
Output is correct |
11 |
Correct |
6 ms |
2984 KB |
Output is correct |
12 |
Correct |
6 ms |
3072 KB |
Output is correct |
13 |
Correct |
4 ms |
2944 KB |
Output is correct |
14 |
Correct |
6 ms |
3072 KB |
Output is correct |
15 |
Correct |
6 ms |
2944 KB |
Output is correct |
16 |
Correct |
5 ms |
2816 KB |
Output is correct |
17 |
Correct |
6 ms |
2816 KB |
Output is correct |
18 |
Correct |
14 ms |
2816 KB |
Output is correct |
19 |
Correct |
10 ms |
3328 KB |
Output is correct |
20 |
Correct |
11 ms |
3328 KB |
Output is correct |
21 |
Correct |
10 ms |
3328 KB |
Output is correct |
22 |
Correct |
105 ms |
16988 KB |
Output is correct |
23 |
Correct |
152 ms |
16892 KB |
Output is correct |
24 |
Correct |
126 ms |
17144 KB |
Output is correct |
25 |
Correct |
119 ms |
17204 KB |
Output is correct |
26 |
Correct |
117 ms |
17192 KB |
Output is correct |
27 |
Correct |
16 ms |
3968 KB |
Output is correct |
28 |
Correct |
18 ms |
3968 KB |
Output is correct |
29 |
Correct |
11 ms |
3968 KB |
Output is correct |
30 |
Correct |
289 ms |
31360 KB |
Output is correct |
31 |
Correct |
273 ms |
31344 KB |
Output is correct |
32 |
Correct |
264 ms |
31352 KB |
Output is correct |
33 |
Correct |
106 ms |
15096 KB |
Output is correct |
34 |
Correct |
107 ms |
15028 KB |
Output is correct |
35 |
Correct |
132 ms |
14872 KB |
Output is correct |
36 |
Execution timed out |
3046 ms |
289244 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2688 KB |
Output is correct |
2 |
Correct |
5 ms |
2688 KB |
Output is correct |
3 |
Correct |
4 ms |
2732 KB |
Output is correct |
4 |
Correct |
4 ms |
2816 KB |
Output is correct |
5 |
Correct |
4 ms |
2688 KB |
Output is correct |
6 |
Correct |
4 ms |
2688 KB |
Output is correct |
7 |
Correct |
4 ms |
2688 KB |
Output is correct |
8 |
Correct |
5 ms |
2688 KB |
Output is correct |
9 |
Correct |
4 ms |
2688 KB |
Output is correct |
10 |
Correct |
6 ms |
2688 KB |
Output is correct |
11 |
Correct |
6 ms |
2984 KB |
Output is correct |
12 |
Correct |
6 ms |
3072 KB |
Output is correct |
13 |
Correct |
4 ms |
2944 KB |
Output is correct |
14 |
Correct |
6 ms |
3072 KB |
Output is correct |
15 |
Correct |
6 ms |
2944 KB |
Output is correct |
16 |
Correct |
5 ms |
2816 KB |
Output is correct |
17 |
Correct |
6 ms |
2816 KB |
Output is correct |
18 |
Correct |
14 ms |
2816 KB |
Output is correct |
19 |
Correct |
10 ms |
3328 KB |
Output is correct |
20 |
Correct |
11 ms |
3328 KB |
Output is correct |
21 |
Correct |
10 ms |
3328 KB |
Output is correct |
22 |
Correct |
105 ms |
16988 KB |
Output is correct |
23 |
Correct |
152 ms |
16892 KB |
Output is correct |
24 |
Correct |
126 ms |
17144 KB |
Output is correct |
25 |
Correct |
119 ms |
17204 KB |
Output is correct |
26 |
Correct |
117 ms |
17192 KB |
Output is correct |
27 |
Correct |
323 ms |
37284 KB |
Output is correct |
28 |
Correct |
351 ms |
37244 KB |
Output is correct |
29 |
Correct |
295 ms |
37112 KB |
Output is correct |
30 |
Correct |
263 ms |
37368 KB |
Output is correct |
31 |
Correct |
691 ms |
37752 KB |
Output is correct |
32 |
Correct |
2797 ms |
170836 KB |
Output is correct |
33 |
Correct |
1029 ms |
44100 KB |
Output is correct |
34 |
Correct |
1354 ms |
62968 KB |
Output is correct |
35 |
Correct |
5 ms |
2688 KB |
Output is correct |
36 |
Execution timed out |
3065 ms |
279296 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |