답안 #124218

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124218 2019-07-02T18:48:03 Z tutis 원 고르기 (APIO18_circle_selection) C++17
23 / 100
2276 ms 81376 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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
ll h(ll x, ll y)
{
	ll ret = x + 156764 * y;
	ret %= 300000;
	return ret;
}
list<int>xx[300000];
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);
	list<ll>liko;
	list<ll>::iterator itas[n];
	for (ll i = 0; i < n; i++)
	{
		liko.push_back(i);
		itas[i] = (--liko.end());
	}
	for (int i = 0; i < 300000; i++)
		xx[i].clear();
	for (ll i = 0; i < n; i++)
	{
		xx[ h(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;
			for (int c = 0; c < 300000; c++)
				xx[c].clear();
			for (ll i : liko)
			{
				xx[h(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<int>&kvad = xx[h(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";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Runtime error 22 ms 14812 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 282 ms 81376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 18 ms 14712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1470 ms 42212 KB Output is correct
2 Correct 2276 ms 42264 KB Output is correct
3 Correct 754 ms 50296 KB Output is correct
4 Correct 1790 ms 49656 KB Output is correct
5 Correct 1735 ms 49824 KB Output is correct
6 Correct 882 ms 50172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Runtime error 22 ms 14812 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Runtime error 22 ms 14812 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -