Submission #50088

# Submission time Handle Problem Language Result Execution time Memory
50088 2018-06-07T13:49:47 Z zetapi Circle selection (APIO18_circle_selection) C++14
0 / 100
610 ms 39416 KB
#include <bits/stdc++.h>
using namespace std;
 
#define pb  push_back
#define mp  make_pair
#define int long long
#define itr ::iterator 
 
typedef pair<int,int>  pii;
 
const int MAX=4e5;
const int INF=1e12;
 
set<int> st;
 
vector< vector<pii> > vec(MAX);
 
int N,mnx,mny,X[MAX],Y[MAX],R[MAX],par[MAX],block[MAX][2];
 
bool ok(int F,int S)
{
	if((X[F]-X[S])*(X[F]-X[S])+(Y[F]-Y[S])*(Y[F]-Y[S])>(R[F]+R[S])*(R[F]+R[S]))
		return false;
	return true;
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	/*cin.tie(0);
	cout.tie(0);*/
 	
 	/* 	input
 		11
		9 9 2
		13 2 1
		11 8 2
		3 3 2
		3 12 1
		12 14 1
		9 8 5
		2 8 2
		5 2 1
		14 4 2
		14 14 1
	*/
 	mnx=INF;
 	mny=INF;
	cin>>N;
	for(int A=1;A<=N;A++)
	{
		cin>>X[A]>>Y[A]>>R[A];
		mnx=min(mnx,X[A]);
		mnx=min(mnx,Y[A]);
	}
	for(int A=1;A<=N;A++)
	{
		X[A]-=mnx;
		Y[A]-=mnx;
		block[A][0]=X[A]/R[A];
		block[A][1]=Y[A]/R[A];
		vec[block[A][1]].pb(mp(block[A][0],A));
		st.insert(block[A][1]);
	}
	for(auto A:st)
		sort(vec[A].begin(),vec[A].end());
	for(int A=1;A<=N;A++)
	{
		if(par[A])
			continue;
		par[A]=A;
		for(int B=block[A][1]-2;B<=block[A][1]+2;B++)
		{
			if(B<0)
				continue;
			if(vec[B].empty())
				continue;
			pii lol=mp(block[A][0]-2,0);
			for(vector<pii> itr it=lower_bound(vec[B].begin(),vec[B].end(),lol);it!=vec[B].end() and block[it->second][0]<=block[A][0]+2;it++)
			{
				if(par[it->second])
					continue;
				if(ok(A,it->second))
					par[it->second]=A;
			}
		}
	}
	for(int A=1;A<=N;A++)
		cout<<par[A]<<" ";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 9720 KB Output is correct
2 Correct 12 ms 9828 KB Output is correct
3 Correct 11 ms 9828 KB Output is correct
4 Incorrect 10 ms 9880 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 209 ms 30120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 30120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 610 ms 39416 KB Output is correct
2 Runtime error 140 ms 39416 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 9720 KB Output is correct
2 Correct 12 ms 9828 KB Output is correct
3 Correct 11 ms 9828 KB Output is correct
4 Incorrect 10 ms 9880 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 9720 KB Output is correct
2 Correct 12 ms 9828 KB Output is correct
3 Correct 11 ms 9828 KB Output is correct
4 Incorrect 10 ms 9880 KB Output isn't correct
5 Halted 0 ms 0 KB -