Submission #124216

# Submission time Handle Problem Language Result Execution time Memory
124216 2019-07-02T18:39:32 Z tutis Circle selection (APIO18_circle_selection) C++17
37 / 100
3000 ms 180444 KB
/*input
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
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios_base::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll x[n], y[n], r[n];
	for (ll i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i] >> r[i];
		x[i] += ll(1e9);
		y[i] += ll(1e9);
	}
	ll a[n];
	iota(a, a + n, 0);
	sort(a, a + n, [&](ll x, ll y) {
		if (r[x] != r[y])
			return r[x] > r[y];
		else
			return x < y;
	});
	ll ans[n];
	fill_n(ans, n, -1);
	ll g = (1 << 30);
	map<pair<ll, ll>, list<ll>>xx;
	list<ll>liko;
	list<ll>::iterator itas[n];
	for (ll i = 0; i < n; i++)
	{
		liko.push_back(i);
		itas[i] = (--liko.end());
	}
	xx.clear();
	for (ll i = 0; i < n; i++)
	{
		xx[ {x[i] / g, y[i] / g}].push_back(i);
	}
	for (ll i = 0; i < n; i++)
	{
		if (ans[a[i]] != -1)
			continue;
		while (g >= r[a[i]] * 2)
		{
			g /= 2;
			xx.clear();
			for (ll i : liko)
			{
				xx[ {x[i] / g, y[i] / g}].push_back(i);
			}
		}
		ll aa = x[a[i]] / g;
		ll bb = y[a[i]] / g;
		for (ll dx = -2; dx <= 2; dx++)
		{
			for (ll dy = -2; dy <= 2; dy++)
			{
				list<ll>&kvad = xx[ {aa + dx, bb + dy}];
				for (auto it = kvad.begin(); it != kvad.end();)
				{
					ll j = *it;
					if ((x[a[i]] - x[j]) * (x[a[i]] - x[j]) +
					        (y[a[i]] - y[j]) * (y[a[i]] - y[j]) <=
					        (r[a[i]] + r[j]) * (r[a[i]] + r[j]))
					{
						ans[j] = a[i];
						liko.erase(itas[j]);
						it = kvad.erase(it);
					}
					else
						it++;
				}
			}
		}
	}
	for (ll i = 0; i < n; i++)
		cout << ans[i] + 1 << " ";
	cout << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 6 ms 888 KB Output is correct
20 Correct 6 ms 888 KB Output is correct
21 Correct 7 ms 892 KB Output is correct
22 Correct 57 ms 5112 KB Output is correct
23 Correct 60 ms 5368 KB Output is correct
24 Correct 57 ms 4344 KB Output is correct
25 Correct 60 ms 4988 KB Output is correct
26 Correct 59 ms 5296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 270 ms 35280 KB Output is correct
2 Correct 319 ms 35300 KB Output is correct
3 Correct 299 ms 35196 KB Output is correct
4 Correct 246 ms 35388 KB Output is correct
5 Correct 1408 ms 36088 KB Output is correct
6 Execution timed out 3038 ms 81528 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1969 ms 91508 KB Output is correct
3 Execution timed out 3045 ms 81344 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3058 ms 57092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 6 ms 888 KB Output is correct
20 Correct 6 ms 888 KB Output is correct
21 Correct 7 ms 892 KB Output is correct
22 Correct 57 ms 5112 KB Output is correct
23 Correct 60 ms 5368 KB Output is correct
24 Correct 57 ms 4344 KB Output is correct
25 Correct 60 ms 4988 KB Output is correct
26 Correct 59 ms 5296 KB Output is correct
27 Correct 11 ms 1400 KB Output is correct
28 Correct 11 ms 1528 KB Output is correct
29 Correct 10 ms 1528 KB Output is correct
30 Correct 125 ms 11128 KB Output is correct
31 Correct 128 ms 11128 KB Output is correct
32 Correct 123 ms 8568 KB Output is correct
33 Correct 87 ms 11912 KB Output is correct
34 Correct 87 ms 11900 KB Output is correct
35 Correct 107 ms 11932 KB Output is correct
36 Correct 2028 ms 100216 KB Output is correct
37 Correct 2074 ms 90716 KB Output is correct
38 Correct 2096 ms 103932 KB Output is correct
39 Correct 891 ms 33756 KB Output is correct
40 Correct 911 ms 33912 KB Output is correct
41 Correct 859 ms 33728 KB Output is correct
42 Correct 515 ms 18552 KB Output is correct
43 Correct 1794 ms 179960 KB Output is correct
44 Correct 1704 ms 180240 KB Output is correct
45 Correct 1680 ms 179960 KB Output is correct
46 Correct 1781 ms 180216 KB Output is correct
47 Correct 1970 ms 180332 KB Output is correct
48 Correct 1709 ms 180316 KB Output is correct
49 Correct 1742 ms 180444 KB Output is correct
50 Correct 1871 ms 180016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 6 ms 888 KB Output is correct
20 Correct 6 ms 888 KB Output is correct
21 Correct 7 ms 892 KB Output is correct
22 Correct 57 ms 5112 KB Output is correct
23 Correct 60 ms 5368 KB Output is correct
24 Correct 57 ms 4344 KB Output is correct
25 Correct 60 ms 4988 KB Output is correct
26 Correct 59 ms 5296 KB Output is correct
27 Correct 270 ms 35280 KB Output is correct
28 Correct 319 ms 35300 KB Output is correct
29 Correct 299 ms 35196 KB Output is correct
30 Correct 246 ms 35388 KB Output is correct
31 Correct 1408 ms 36088 KB Output is correct
32 Execution timed out 3038 ms 81528 KB Time limit exceeded
33 Halted 0 ms 0 KB -