Submission #698763

# Submission time Handle Problem Language Result Execution time Memory
698763 2023-02-14T09:30:10 Z vjudge1 Circle selection (APIO18_circle_selection) C++17
0 / 100
598 ms 8268 KB
#include <bits/stdc++.h>
#include <array>
#define all(v) (v.begin()), (v.end())
#define setall(a, val) for(auto& x : a) x = val
#define ll long long
clock_t start_time;
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
void init() {
#ifndef ONLINE_JUDGE
	FILE* _ = freopen("in.txt", "r", stdin);
	start_time = clock();
#endif
}
const ll MOD = 998244353;
const ll N = 6e5 + 1;
const ll M = 2e2 + 1;
using namespace std;
//####################################################################################

bool comp(array<int, 4> a, array<int, 4> b) {
	if (a[0] == b[0])
		return a[3] < b[3];
	return a[0] > b[0];
}

double dist(int x1, int y1, int x2, int y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(0)); //init();

	int n;
	cin >> n;
	vector< array<int, 4> > v(n); // {radius, x, y, idx}
	for (int i = 0; i < n; i++)
		cin >> v[i][1] >> v[i][2] >> v[i][0], v[i][3] = i + 1;
	sort(all(v), comp);

	int cnt = n;
	vector<int> ans(n + 1, 0);
	while (cnt) {
		int idx = INT_MAX, mx = 0;
		for (int i = 0; i < n; i++) {
			if (ans[v[i][3]])
				continue;

			if (v[i][0] > mx)
				mx = v[i][0], idx = i;
			if (v[i][0] == mx && i < idx)
				idx = i;
		}

		for (int i = 0; i < n; i++) {
			if (!ans[v[i][3]] && dist(v[idx][1], v[idx][2], v[i][1], v[i][2]) <= v[idx][0] + v[i][0])
				ans[v[i][3]] = v[idx][3], cnt--;
		}
	}

	for (int i = 1; i <= n; i++) {
		cout << ans[i];
		if (i != n)
			cout << ' ';
		else
			cout << endl;
	}

	//cerr << get_time() << "s" << endl;
}

Compilation message

circle_selection.cpp: In function 'void init()':
circle_selection.cpp:10:8: warning: unused variable '_' [-Wunused-variable]
   10 |  FILE* _ = freopen("in.txt", "r", stdin);
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 8268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 598 ms 7116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -