Submission #1201663

#TimeUsernameProblemLanguageResultExecution timeMemory
1201663crispxxCircle selection (APIO18_circle_selection)C++20
7 / 100
3094 ms32856 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define ar array
#define nl '\n'

template <typename A, typename B>
bool chmin(A &a, const B &b) {
	if(a > b) {
		return a = b, true;
	}
	return false;
}

template <typename A, typename B>
bool chmax(A &a, const B &b) {
	if(a < b) {
		return a = b, true;
	}
	return false;
}

void solve() {
	int n; cin >> n;
	
	vector<int> x(n), y(n), r(n);
	
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> r[i];
	}
	
	set<pair<int, int>, greater<>> st;
	
	for(int i = 0; i < n; i++) {
		st.emplace(r[i], -i);
	}
	
	vector<int> deled(n);
	
	while(!st.empty()) {
		auto [rad, i] = *st.begin();
		i = -i;
		vector<int> del;
		for(auto [rad2, j] : st) {
			j = -j;
			int a = x[i] - x[j], b = y[i] - y[j], c = r[i] + r[j];
			if(a * a + b * b <= c * c) {
				del.pb(j);
			}
		}
		for(auto j : del) {
			st.erase({r[j], -j});
			deled[j] = i;
		}
	}
	
	for(auto i : deled) cout << i + 1 << ' ';
	cout << nl;
}

/**

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


**/

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	solve();
}
#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...