답안 #106709

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106709 2019-04-19T18:47:40 Z chemistrae03 원 고르기 (APIO18_circle_selection) C++17
0 / 100
4 ms 1380 KB
#include <bits/stdc++.h>

using namespace std;

struct Circle {
	int x, y, r, i;
	Circle(int _x, int _y, int _r, int _i) : x(_x), y(_y), r(_r), i(_i) {
		// do nothing
	}
	bool intercept(const Circle &c) {
		int dx = c.x - x, dy = c.y - y, dr = c.r + r;
		// cerr << dx << ' ' << dy << ' ' << dr << '\n';
		if (dx * dx + dy * dy <= dr * dr) {
			return true;
		}
		return false;
	}
	bool operator < (const Circle &c) { 
		return 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, y, r, i + 1);
	}
	sort(v.begin(), v.end());
	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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -