Submission #835555

# Submission time Handle Problem Language Result Execution time Memory
835555 2023-08-23T15:52:52 Z jamielim Circle selection (APIO18_circle_selection) C++14
0 / 100
3000 ms 552500 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
typedef vector<int> vi;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
 
int n;
i4 arr[300005];
int X[300005],Y[300005],R[300005];
int proc=0;
int ans[300005];
int scale=(1<<30);
map<ii,vector<int> > m;
 
inline void downscale(){
	m.clear();
	for(int x=proc;x<n;x++){
		i4 i=arr[x];
		if(ans[-i.fi.se]==-1)m[mp(i.se.fi/scale,i.se.se/scale)].pb(-i.fi.se);
	}
}
 
inline bool intersect(int a,int b){
	ll dx=X[a]-X[b];
	ll dy=Y[a]-Y[b];
	ll r=R[a]+R[b];
	return (dx*dx<=r*r-dy*dy);
}
 
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&X[i],&Y[i],&R[i]);
		X[i]+=INF;Y[i]+=INF;
		arr[i]=mp(mp(R[i],-i),mp(X[i],Y[i]));
	}
	memset(ans,-1,sizeof(ans));
	sort(arr,arr+n);
	reverse(arr,arr+n);
	downscale();
	for(;proc<n;proc++){
		i4 cur=arr[proc];
		int index=-cur.fi.se;
		if(ans[index]!=-1)continue;
		bool change=0;
		while(scale>cur.fi.fi){scale/=2;change=1;}
		if(change)downscale();
		
		int x=cur.se.fi/scale,y=cur.se.se/scale;
		for(int i=x-2;i<=x+2;i++){
			for(int j=y-2;j<=y+2;j++){
				vector<int> v1=m[mp(i,j)];
				vector<int> v2;
				for(int k:v1){
					if(intersect(k,index)){
						ans[k]=index;
					}else{
						v2.pb(k);
					}
				}
				swap(m[mp(i,j)],v2);
			}
		}
	}
	for(int i=0;i<n;i++)printf("%d ",ans[i]+1);
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
circle_selection.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |   scanf("%d%d%d",&X[i],&Y[i],&R[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Incorrect 1 ms 1492 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 129 ms 13592 KB Output is correct
2 Incorrect 131 ms 13516 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Incorrect 1353 ms 89272 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3055 ms 552500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Incorrect 1 ms 1492 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Incorrect 1 ms 1492 KB Output isn't correct
11 Halted 0 ms 0 KB -