답안 #252468

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252468 2020-07-25T16:01:15 Z Saboon 원 고르기 (APIO18_circle_selection) C++14
0 / 100
104 ms 4520 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 20;
const int inf = 1e9;

int c[maxn], r[maxn], p[maxn], pos[maxn], q[maxn];

ll dis(int x, int y, int X, int Y){
	return 1ll*(x-X)*(x-X) + 1ll*(y-Y)*(y-Y);
}

int x[maxn], y[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> x[i] >> y[i] >> r[i];

	for (int i = 1; i <= n; i++)
		p[i] = i, q[i] = i;
	sort(q+1, q+n+1, [](int a, int b){
		return x[a] < x[b];
	});
	for (int i = 1; i <= n; i++)
		pos[q[i]] = i;
	
	sort(p+1, p+n+1, [](int a, int b){
		if (r[a] != r[b])
			return r[a] > r[b];
		return a < b;
	});
	for (int za = 1; za <= n; za++){
		int i = p[za];
		if (c[pos[i]] != 0)
			continue;
		c[i] = i;
		for (int j = pos[i]+1; j <= n; j++){
			if (c[j] != 0 or dis(x[i], y[i], x[q[j]], y[q[j]]) > 1ll*(r[i]+r[q[j]])*(r[i]+r[q[j]]))
				break;
			c[j] = i;
		}
		for (int j = pos[i]-1; j >= 1; j--){
			if (c[j] != 0 or dis(x[i], y[i], x[q[j]], y[q[j]]) > 1ll*(r[i]+r[q[j]])*(r[i]+r[q[j]]))
				break;
			c[j] = i;
		}
	}
	for (int i = 1; i <= n; i++)
		cout << c[i] << " \n"[i == n];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 0 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 74 ms 4472 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 104 ms 4520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 0 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 0 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -