Submission #106712

# Submission time Handle Problem Language Result Execution time Memory
106712 2019-04-19T18:56:16 Z chemistrae03 Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 7776 KB
#include <bits/stdc++.h>

using namespace std;

struct Circle {
	long long x, y, r;
	int i;
	Circle(long long _x, long long _y, long long _r, int _i) : x(_x), y(_y), r(_r), i(_i) {
		// do nothing
	}
	bool intercept(const Circle &c) {
		long long dx = c.x - x, dy = c.y - y, dr = c.r + r;
		// cerr << dx << ' ' << dy << ' ' << dr << '\n';
		if (dx * dx * 1LL + dy * dy * 1LL <= dr * dr * 1LL) {
			return true;
		} else {
			return false;
		}
	}
	bool operator < (const Circle &c) { 
		return r == c.r ? i < c.i : r > c.r;
	}
};

const int MAX = 1e5 + 9;
vector<Circle> v;
int parent[MAX];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// Circle c1 = Circle(9, 8, 5, 1);
	// Circle c2 = Circle(2, 8, 2, 1);
	// cerr << c1.intercept(c2) << '\n';
	// return 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		parent[i] = i;
	}
	for (int i = 0; i < n; i++) {
		int x, y, r;
		cin >> x >> y >> r;
		v.emplace_back(x * 1LL, y * 1LL, r * 1LL, i + 1);
	}
	sort(v.begin(), v.end());
	// for (auto vv : v) {
	// 	cerr << vv.i << '\n';
	// }
	// return 0;
	for (auto vv : v) {
		if (parent[vv.i] == vv.i) {
			for (auto vvv : v) {
				if (parent[vvv.i] != vvv.i) {
					continue;
				}
				if (vv.intercept(vvv)) {
					parent[vvv.i] = vv.i;
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << parent[i] << ' ';
	}
	cout << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 392 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 6 ms 896 KB Output is correct
20 Correct 5 ms 896 KB Output is correct
21 Correct 6 ms 896 KB Output is correct
22 Correct 57 ms 896 KB Output is correct
23 Correct 58 ms 896 KB Output is correct
24 Correct 62 ms 888 KB Output is correct
25 Correct 59 ms 896 KB Output is correct
26 Correct 53 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Execution timed out 3012 ms 7020 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 392 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 6 ms 896 KB Output is correct
20 Correct 5 ms 896 KB Output is correct
21 Correct 6 ms 896 KB Output is correct
22 Correct 57 ms 896 KB Output is correct
23 Correct 58 ms 896 KB Output is correct
24 Correct 62 ms 888 KB Output is correct
25 Correct 59 ms 896 KB Output is correct
26 Correct 53 ms 896 KB Output is correct
27 Correct 13 ms 1408 KB Output is correct
28 Correct 11 ms 1280 KB Output is correct
29 Correct 8 ms 1280 KB Output is correct
30 Correct 214 ms 1280 KB Output is correct
31 Correct 257 ms 1280 KB Output is correct
32 Correct 217 ms 1280 KB Output is correct
33 Correct 58 ms 7776 KB Output is correct
34 Correct 62 ms 7648 KB Output is correct
35 Correct 105 ms 7520 KB Output is correct
36 Execution timed out 3031 ms 6892 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 392 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 6 ms 896 KB Output is correct
20 Correct 5 ms 896 KB Output is correct
21 Correct 6 ms 896 KB Output is correct
22 Correct 57 ms 896 KB Output is correct
23 Correct 58 ms 896 KB Output is correct
24 Correct 62 ms 888 KB Output is correct
25 Correct 59 ms 896 KB Output is correct
26 Correct 53 ms 896 KB Output is correct
27 Runtime error 4 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Halted 0 ms 0 KB -