답안 #982240

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982240 2024-05-14T04:25:18 Z Faisal_Saqib 원 고르기 (APIO18_circle_selection) C++17
22 / 100
2257 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=3e5+100;
const int SQ=666;//  333 444
vector<int> adj[N];
ll who[N];
void solve()
{
	ll n;
	cin>>n;
	vector<ll> x(n),y(n),r(n);
	for(int i=0;i<n;i++)
		cin>>x[i]>>y[i]>>r[i];
	if((n<=5000))
	{
		for(int i=0;i<n;i++)
			{
				for(int j=0;j<=i;j++)
				{
					// ( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) <= (r1+r2)²
					ll dist=(r[i]+r[j])*(r[i]+r[j]);
					ll dp=( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
					if(dp<=dist)
					{
						adj[i].push_back(j);
						adj[j].push_back(i);
					}
				}
			}
			set<pair<int,int>> rem;
			for(int i=0;i<n;i++)
				rem.insert({-r[i],i});
			while(rem.size())
			{
				auto p=*begin(rem);
				rem.erase(begin(rem));
				if(who[p.second]!=0)
					continue;
				for(auto op:adj[p.second])
					if(who[op]==0)
						who[op]=p.second+1;
			}
			for(int i=0;i<n;i++)
			{
				cout<<who[i]<<' ';
			}
			cout<<'\n';
	}
	else
	{
		
		vector<pair<ll,ll>> tp(n);
		for(int i=0;i<n;i++)
		{
			tp[i].first=x[i];
			tp[i].second=i;
		}
		sort(begin(tp),end(tp));
		for(int jp=0;jp<n;jp++)
		{
			for(int l=0;l<=SQ;l++)
			{
				if((jp+l)<n)
				{
					int i=tp[jp].second;
					int j=tp[jp+l].second;
					ll dist=(r[i]+r[j])*(r[i]+r[j]);
					ll dp=( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
					if(dp<=dist)
					{
						adj[i].push_back(j);
						adj[j].push_back(i);
					}
				}
			}
		}
		set<pair<int,int>> rem;
		for(int i=0;i<n;i++)
			rem.insert({-r[i],i});
		while(rem.size())
		{
			auto p=*begin(rem);
			rem.erase(begin(rem));
			if(who[p.second]!=0)
				continue;
			for(auto op:adj[p.second])
				if(who[op]==0)
					who[op]=p.second+1;
		}
		for(int i=0;i<n;i++)
		{
			cout<<who[i]<<' ';
		}
		cout<<'\n';
	}
}
int main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 2 ms 7516 KB Output is correct
3 Correct 2 ms 7636 KB Output is correct
4 Correct 3 ms 7516 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 2 ms 7516 KB Output is correct
7 Correct 2 ms 7516 KB Output is correct
8 Correct 2 ms 7516 KB Output is correct
9 Correct 2 ms 7516 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 7516 KB Output is correct
12 Correct 2 ms 7516 KB Output is correct
13 Correct 2 ms 7516 KB Output is correct
14 Correct 2 ms 7516 KB Output is correct
15 Correct 2 ms 7516 KB Output is correct
16 Correct 8 ms 11360 KB Output is correct
17 Correct 8 ms 11352 KB Output is correct
18 Correct 9 ms 11608 KB Output is correct
19 Correct 201 ms 145112 KB Output is correct
20 Correct 195 ms 143636 KB Output is correct
21 Correct 170 ms 84816 KB Output is correct
22 Correct 26 ms 8016 KB Output is correct
23 Correct 27 ms 8360 KB Output is correct
24 Correct 27 ms 8020 KB Output is correct
25 Correct 28 ms 8028 KB Output is correct
26 Correct 34 ms 8620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2257 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 269 ms 20656 KB Output is correct
3 Correct 1004 ms 47080 KB Output is correct
4 Correct 1051 ms 46876 KB Output is correct
5 Correct 1063 ms 45904 KB Output is correct
6 Correct 458 ms 28068 KB Output is correct
7 Correct 244 ms 18248 KB Output is correct
8 Correct 43 ms 9620 KB Output is correct
9 Correct 1085 ms 46944 KB Output is correct
10 Correct 1080 ms 46868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 854 ms 46876 KB Output is correct
2 Correct 921 ms 46872 KB Output is correct
3 Incorrect 1284 ms 79624 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 2 ms 7516 KB Output is correct
3 Correct 2 ms 7636 KB Output is correct
4 Correct 3 ms 7516 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 2 ms 7516 KB Output is correct
7 Correct 2 ms 7516 KB Output is correct
8 Correct 2 ms 7516 KB Output is correct
9 Correct 2 ms 7516 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 7516 KB Output is correct
12 Correct 2 ms 7516 KB Output is correct
13 Correct 2 ms 7516 KB Output is correct
14 Correct 2 ms 7516 KB Output is correct
15 Correct 2 ms 7516 KB Output is correct
16 Correct 8 ms 11360 KB Output is correct
17 Correct 8 ms 11352 KB Output is correct
18 Correct 9 ms 11608 KB Output is correct
19 Correct 201 ms 145112 KB Output is correct
20 Correct 195 ms 143636 KB Output is correct
21 Correct 170 ms 84816 KB Output is correct
22 Correct 26 ms 8016 KB Output is correct
23 Correct 27 ms 8360 KB Output is correct
24 Correct 27 ms 8020 KB Output is correct
25 Correct 28 ms 8028 KB Output is correct
26 Correct 34 ms 8620 KB Output is correct
27 Incorrect 89 ms 66388 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7516 KB Output is correct
2 Correct 2 ms 7516 KB Output is correct
3 Correct 2 ms 7636 KB Output is correct
4 Correct 3 ms 7516 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 2 ms 7516 KB Output is correct
7 Correct 2 ms 7516 KB Output is correct
8 Correct 2 ms 7516 KB Output is correct
9 Correct 2 ms 7516 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 7516 KB Output is correct
12 Correct 2 ms 7516 KB Output is correct
13 Correct 2 ms 7516 KB Output is correct
14 Correct 2 ms 7516 KB Output is correct
15 Correct 2 ms 7516 KB Output is correct
16 Correct 8 ms 11360 KB Output is correct
17 Correct 8 ms 11352 KB Output is correct
18 Correct 9 ms 11608 KB Output is correct
19 Correct 201 ms 145112 KB Output is correct
20 Correct 195 ms 143636 KB Output is correct
21 Correct 170 ms 84816 KB Output is correct
22 Correct 26 ms 8016 KB Output is correct
23 Correct 27 ms 8360 KB Output is correct
24 Correct 27 ms 8020 KB Output is correct
25 Correct 28 ms 8028 KB Output is correct
26 Correct 34 ms 8620 KB Output is correct
27 Runtime error 2257 ms 1048576 KB Execution killed with signal 9
28 Halted 0 ms 0 KB -