Submission #387618

# Submission time Handle Problem Language Result Execution time Memory
387618 2021-04-09T04:09:05 Z milleniumEeee Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 28076 KB
#include <bits/stdc++.h>
#define fastInp ios_base::sync_with_stdio(0); cin.tie(0);
#define pii pair<int, int>
#define fr first
#define sc second
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define mk make_pair
#define int long long
using namespace std;

const int MAXN = (int)3e5 + 5;

int n;

int x[MAXN];
int y[MAXN];
int rad[MAXN];

vector <int> g[MAXN];

double get_dist(int i, int j) {
	return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
}

bool intersect(int i, int j) {
	return (get_dist(i, j) <= (rad[i] + rad[j]) * (rad[i] + rad[j]));
}

int ans[MAXN];

signed main() {
	fastInp;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i] >> rad[i];
	}
	vector <int> pos;
	for (int i = 1; i <= n; i++) {
		pos.pb(i);
	}
	sort(all(pos), [&](int A, int B) {
		if (rad[A] != rad[B]) {
			return rad[A] > rad[B];
		} else {
			return A < B;
		}
	});
	memset(ans, -1, sizeof(ans));
	for (int el : pos) {
		if (ans[el] == -1) {
			ans[el] = el;
			for (int i = 1; i <= n; i++) {
				if (ans[i] == -1 && intersect(i, el)) {
					ans[i] = el;
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << " ";
	}
}
/*
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 time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9680 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 6 ms 9680 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 6 ms 9680 KB Output is correct
8 Correct 6 ms 9676 KB Output is correct
9 Correct 6 ms 9700 KB Output is correct
10 Correct 6 ms 9676 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 6 ms 9676 KB Output is correct
13 Correct 6 ms 9676 KB Output is correct
14 Correct 6 ms 9676 KB Output is correct
15 Correct 6 ms 9676 KB Output is correct
16 Correct 6 ms 9804 KB Output is correct
17 Correct 7 ms 9804 KB Output is correct
18 Correct 7 ms 9700 KB Output is correct
19 Correct 9 ms 10060 KB Output is correct
20 Correct 9 ms 10132 KB Output is correct
21 Correct 9 ms 10060 KB Output is correct
22 Correct 74 ms 10076 KB Output is correct
23 Correct 75 ms 10080 KB Output is correct
24 Correct 75 ms 10088 KB Output is correct
25 Correct 77 ms 10076 KB Output is correct
26 Correct 76 ms 10060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 169 ms 21252 KB Output is correct
2 Correct 187 ms 27908 KB Output is correct
3 Correct 174 ms 27744 KB Output is correct
4 Correct 167 ms 28076 KB Output is correct
5 Execution timed out 3060 ms 23936 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9660 KB Output is correct
2 Execution timed out 3087 ms 15696 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3079 ms 19128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9680 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 6 ms 9680 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 6 ms 9680 KB Output is correct
8 Correct 6 ms 9676 KB Output is correct
9 Correct 6 ms 9700 KB Output is correct
10 Correct 6 ms 9676 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 6 ms 9676 KB Output is correct
13 Correct 6 ms 9676 KB Output is correct
14 Correct 6 ms 9676 KB Output is correct
15 Correct 6 ms 9676 KB Output is correct
16 Correct 6 ms 9804 KB Output is correct
17 Correct 7 ms 9804 KB Output is correct
18 Correct 7 ms 9700 KB Output is correct
19 Correct 9 ms 10060 KB Output is correct
20 Correct 9 ms 10132 KB Output is correct
21 Correct 9 ms 10060 KB Output is correct
22 Correct 74 ms 10076 KB Output is correct
23 Correct 75 ms 10080 KB Output is correct
24 Correct 75 ms 10088 KB Output is correct
25 Correct 77 ms 10076 KB Output is correct
26 Correct 76 ms 10060 KB Output is correct
27 Correct 11 ms 10528 KB Output is correct
28 Correct 11 ms 10444 KB Output is correct
29 Correct 11 ms 10444 KB Output is correct
30 Correct 315 ms 10464 KB Output is correct
31 Correct 332 ms 10420 KB Output is correct
32 Correct 313 ms 10468 KB Output is correct
33 Correct 63 ms 16704 KB Output is correct
34 Correct 65 ms 16580 KB Output is correct
35 Correct 68 ms 16464 KB Output is correct
36 Execution timed out 3071 ms 15424 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9680 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 6 ms 9680 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 6 ms 9680 KB Output is correct
8 Correct 6 ms 9676 KB Output is correct
9 Correct 6 ms 9700 KB Output is correct
10 Correct 6 ms 9676 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 6 ms 9676 KB Output is correct
13 Correct 6 ms 9676 KB Output is correct
14 Correct 6 ms 9676 KB Output is correct
15 Correct 6 ms 9676 KB Output is correct
16 Correct 6 ms 9804 KB Output is correct
17 Correct 7 ms 9804 KB Output is correct
18 Correct 7 ms 9700 KB Output is correct
19 Correct 9 ms 10060 KB Output is correct
20 Correct 9 ms 10132 KB Output is correct
21 Correct 9 ms 10060 KB Output is correct
22 Correct 74 ms 10076 KB Output is correct
23 Correct 75 ms 10080 KB Output is correct
24 Correct 75 ms 10088 KB Output is correct
25 Correct 77 ms 10076 KB Output is correct
26 Correct 76 ms 10060 KB Output is correct
27 Correct 169 ms 21252 KB Output is correct
28 Correct 187 ms 27908 KB Output is correct
29 Correct 174 ms 27744 KB Output is correct
30 Correct 167 ms 28076 KB Output is correct
31 Execution timed out 3060 ms 23936 KB Time limit exceeded
32 Halted 0 ms 0 KB -