Submission #252473

# Submission time Handle Problem Language Result Execution time Memory
252473 2020-07-25T16:06:56 Z Saboon Circle selection (APIO18_circle_selection) C++14
0 / 100
221 ms 10756 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 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[pos[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[pos[i]] << " \n"[i == n];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 0 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 221 ms 10756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 10616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 0 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 0 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -