Submission #49967

# Submission time Handle Problem Language Result Execution time Memory
49967 2018-06-05T15:33:02 Z zetapi Circle selection (APIO18_circle_selection) C++14
0 / 100
1178 ms 109008 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=1e9;

set<pii> st;
set<pii> itr it;

priority_queue<pii> pq;

pii cur;

int N,X[MAX],Y[MAX],R[MAX],mark[MAX],par[MAX];

signed main()
{
	ios_base::sync_with_stdio(false);
	/*cin.tie(0);
	cout.tie(0);*/

	cin>>N;
	for(int A=1;A<=N;A++)
	{
		cin>>X[A]>>Y[A]>>R[A];
		X[A]=X[A]-R[A];
		Y[A]=X[A]+R[A]+R[A];
		pq.push(mp(R[A],-A));
	}
	for(int A=1;A<=N;A++)
	{
		st.insert(mp(X[A],A));
		st.insert(mp(Y[A],A));
	}
	while(!pq.empty())
	{
		cur=pq.top();
		pq.pop();
		cur.second*=-1;
		if(mark[cur.second])
			continue;
		par[cur.second]=cur.second;
		st.erase(st.find(mp(X[cur.second],cur.second)));
		st.erase(st.find(mp(Y[cur.second],cur.second)));
		while(true)
		{
			if(st.empty())
				break;
			it=st.lower_bound(mp(X[cur.second],-INF));
			if(X[it->second]>Y[cur.second])
				break;
			mark[it->second]=1;
			par[it->second]=cur.second;
			st.erase(it);
		}
	}
	for(int A=1;A<=N;A++)
		cout<<par[A]<<" ";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 2 ms 428 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1178 ms 108820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 108820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 845 ms 109008 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 2 ms 428 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 2 ms 428 KB Output isn't correct
4 Halted 0 ms 0 KB -