제출 #673306

#제출 시각아이디문제언어결과실행 시간메모리
673306Dan4Life원 고르기 (APIO18_circle_selection)C++17
0 / 100
3078 ms14128 KiB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long 
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
using ll = long long;
const int maxn = (int)3e5+10;
const ll LINF = (ll)2e18;
struct circle{
	int x, y, r, i;
};

int n, elim[maxn];
vector<circle> v;

int poww(int a, int b){
	if(b==0) return 1;
	int x = poww(a,b/2); x*=x;
	if(b&1) x*=a;
	return x;
}

bool intersects(int i, int j){
	return poww(v[i].r+v[j].r,2)-poww(abs(v[i].y-v[j].y),2)>=poww(abs(v[i].x-v[j].x),2);
}

int32_t main(){
	cin >> n; v.resize(n);
	for(int i = 0; i < n; i++){
		cin >> v[i].x >> v[i].y >> v[i].r; 
		v[i].i=i; elim[i]=-1;
	}
	sort(all(v), [&](circle a, circle b){
		if(a.r!=b.r) return a.r > b.r;
		return a.i < b.i;
	});
	for(int i = 0; i < n; i++){
		if(elim[v[i].i]!=-1) continue; 
		elim[v[i].i]=v[i].i;
		for(int j = i; j < n; j++)
			if(intersects(i,j)) elim[v[j].i]=v[i].i;
	}
	for(int i = 0; i < n; i++) cout << elim[i]+1 << " ";
}
/*
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
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...