Submission #49316

#TimeUsernameProblemLanguageResultExecution timeMemory
49316WLZCircle selection (APIO18_circle_selection)C++17
0 / 100
3026 ms14552 KiB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, pair<int, pair<int, int>>> circle;


int n;
bool* used;
vector<circle> v;
vector<int> ans;

int main() {
	scanf("%d", &n);
	used = new bool[n];
	memset(used, 0, sizeof (bool) * n);
	priority_queue<circle> pq;
	ans.resize(n);
	for (int i = 0; i < n; i++) {
		int x, y, r;
		scanf("%d %d %d", &x, &y, &r);
		pq.push({r, {-i, {x, y}}});
		v.push_back({r, {-i, {x, y}}});
	}
	while (!pq.empty()) {
		circle cur = pq.top(); pq.pop();
		int x = cur.second.second.first;
		int y = cur.second.second.second;
		if (used[-cur.second.first]) continue;
		used[-cur.second.first] = true;
		ans[-cur.second.first] = -cur.second.first;
		for (int i = 0; i < n; i++) {
			if (hypot(v[i].second.second.first - x, v[i].second.second.second - y) <= double(cur.first + v[i].first)) {
				used[i] = true;
				ans[i] = -cur.second.first;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (i) printf(" ");
		printf("%d", ans[i] + 1);
	}
	printf("\n");
	return 0;
}

Compilation message (stderr)

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
circle_selection.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &x, &y, &r);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...