Submission #1043474

# Submission time Handle Problem Language Result Execution time Memory
1043474 2024-08-04T09:53:43 Z vjudge1 Circle selection (APIO18_circle_selection) C++17
19 / 100
1300 ms 85688 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

bool inte(vector<int> c,vector<int> c1)
{
	int dis=(c[2]-c1[2])*(c[2]-c1[2])+(c[3]-c1[3])*(c[3]-c1[3]);
	return dis <= (c[0]+c1[0])*(c[0]+c1[0]);
}

signed main()
{
	int n;
	cin>>n;
	int r[n],x[n],y[n],ans[n]={};
	for (int i=0;i<n;i++)
		cin>>x[i]>>y[i]>>r[i];
	if (n<=5000)
	{
		set<vector<int>> se;
		set<int> rem;
		for (int i=0;i<n;i++)
		{
			se.insert({-r[i],i,x[i],y[i]});
			rem.insert(i);
		}
		while (!se.empty())
		{
			auto it=se.begin();
			vector<int> c=*it;c[0]*=-1;
			for (int i:rem)
				if (!ans[i] && inte(c,{r[i],i,x[i],y[i]}))
				{
					se.erase({-r[i],i,x[i],y[i]});
					ans[i]=c[1]+1;
				}
		}
	}
	else
	{
		int mx=-1e9,mn=-mx;
		for (int i=0;i<n;i++)
			mn=min(mn,y[i]),mx=max(mx,y[i]);
		if (!mn && !mx)
		{
			set<pair<int,int>> st,en,rem;
			for (int i=0;i<n;i++)
				st.insert({x[i]-r[i],i}),en.insert({x[i]+r[i],i}),rem.insert({-r[i],i});
			while (!rem.empty())
			{
				set<int> toer;
				auto p=*rem.begin();
				auto it=st.lower_bound({x[p.second]-r[p.second],0});
				auto it1=st.lower_bound({1+x[p.second]+r[p.second],0});
				while (it!=it1)
				{
					toer.insert((*it).second);
					it++;
				}
				it=en.lower_bound({x[p.second]-r[p.second],0});
				it1=en.lower_bound({x[p.second]+r[p.second]+1,0});
				while (it!=it1)
				{
					toer.insert((*it).second);
					it++;
				}
				for (int i:toer)
				{
					ans[i]=p.second+1;
					st.erase({x[i]-r[i],i}),en.erase({x[i]+r[i],i}),rem.erase({-r[i],i});
				}
			}
		}
	}
	for (int i=0;i<n;i++)
		cout<<ans[i]<<' ';
	cout<<endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 416 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 456 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 6 ms 1372 KB Output is correct
20 Correct 6 ms 1372 KB Output is correct
21 Correct 6 ms 1372 KB Output is correct
22 Correct 410 ms 1340 KB Output is correct
23 Correct 405 ms 1340 KB Output is correct
24 Correct 394 ms 1116 KB Output is correct
25 Correct 408 ms 1360 KB Output is correct
26 Correct 406 ms 1336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1300 ms 85628 KB Output is correct
2 Correct 1133 ms 78928 KB Output is correct
3 Correct 1158 ms 83348 KB Output is correct
4 Correct 1202 ms 85688 KB Output is correct
5 Correct 798 ms 70484 KB Output is correct
6 Correct 813 ms 70472 KB Output is correct
7 Correct 838 ms 70656 KB Output is correct
8 Correct 805 ms 70580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 61 ms 3668 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 184 ms 14416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 416 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 456 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 6 ms 1372 KB Output is correct
20 Correct 6 ms 1372 KB Output is correct
21 Correct 6 ms 1372 KB Output is correct
22 Correct 410 ms 1340 KB Output is correct
23 Correct 405 ms 1340 KB Output is correct
24 Correct 394 ms 1116 KB Output is correct
25 Correct 408 ms 1360 KB Output is correct
26 Correct 406 ms 1336 KB Output is correct
27 Incorrect 9 ms 604 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 416 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 456 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 6 ms 1372 KB Output is correct
20 Correct 6 ms 1372 KB Output is correct
21 Correct 6 ms 1372 KB Output is correct
22 Correct 410 ms 1340 KB Output is correct
23 Correct 405 ms 1340 KB Output is correct
24 Correct 394 ms 1116 KB Output is correct
25 Correct 408 ms 1360 KB Output is correct
26 Correct 406 ms 1336 KB Output is correct
27 Correct 1300 ms 85628 KB Output is correct
28 Correct 1133 ms 78928 KB Output is correct
29 Correct 1158 ms 83348 KB Output is correct
30 Correct 1202 ms 85688 KB Output is correct
31 Correct 798 ms 70484 KB Output is correct
32 Correct 813 ms 70472 KB Output is correct
33 Correct 838 ms 70656 KB Output is correct
34 Correct 805 ms 70580 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Incorrect 61 ms 3668 KB Output isn't correct
37 Halted 0 ms 0 KB -