제출 #405144

#제출 시각아이디문제언어결과실행 시간메모리
405144BERNARB01원 고르기 (APIO18_circle_selection)C++17
7 / 100
3074 ms24232 KiB
#include <bits/stdc++.h>

using namespace std;

long double dist(long long x, long long y, long long xx, long long yy) {
	return sqrtl((x - xx) * (x - xx) + (y - yy) * (y - yy));
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> x(n), y(n), r(n);
	set<pair<int, int>> ms;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> r[i];
		ms.insert({-r[i], i});
	}
	vector<int> a(n, -1);
	while (!ms.empty()) {
		int jj = ms.begin()->second;
		a[jj] = jj;
		ms.erase(ms.begin());
		for (int i = 0; i < n; i++) {
			if (a[i] == -1) {
				if (dist(x[i], y[i], x[jj], y[jj]) <= (long double) r[i] + r[jj]) {
					a[i] = jj;
					ms.erase({-r[i], i});
				}
			}
		}
	}
	for (const auto& xx : a) {
		cout << xx + 1 << " ";
	}
	cout << '\n';
	return 0;
}
#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...