답안 #124229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124229 2019-07-02T20:10:02 Z tutis 원 고르기 (APIO18_circle_selection) C++17
87 / 100
3000 ms 45668 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 + 157674864 * y;
	ret %= 300000;
	if (ret < 0)
		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) + 1568;
		y[i] += ll(1e9) + 489484;
	}
	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 14 ms 7416 KB Output is correct
2 Correct 13 ms 7416 KB Output is correct
3 Correct 13 ms 7416 KB Output is correct
4 Correct 17 ms 7416 KB Output is correct
5 Correct 10 ms 7416 KB Output is correct
6 Correct 11 ms 7416 KB Output is correct
7 Correct 11 ms 7416 KB Output is correct
8 Correct 9 ms 7416 KB Output is correct
9 Correct 12 ms 7428 KB Output is correct
10 Correct 11 ms 7416 KB Output is correct
11 Correct 22 ms 7416 KB Output is correct
12 Correct 22 ms 7416 KB Output is correct
13 Correct 21 ms 7416 KB Output is correct
14 Correct 20 ms 7416 KB Output is correct
15 Correct 23 ms 7416 KB Output is correct
16 Correct 15 ms 7544 KB Output is correct
17 Correct 12 ms 7544 KB Output is correct
18 Correct 11 ms 7544 KB Output is correct
19 Correct 13 ms 8184 KB Output is correct
20 Correct 16 ms 8060 KB Output is correct
21 Correct 21 ms 8184 KB Output is correct
22 Correct 39 ms 8184 KB Output is correct
23 Correct 43 ms 8056 KB Output is correct
24 Correct 40 ms 8060 KB Output is correct
25 Correct 39 ms 8060 KB Output is correct
26 Correct 42 ms 8056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 275 ms 44280 KB Output is correct
2 Correct 322 ms 45664 KB Output is correct
3 Correct 305 ms 45516 KB Output is correct
4 Correct 254 ms 45668 KB Output is correct
5 Correct 945 ms 44152 KB Output is correct
6 Correct 1362 ms 44512 KB Output is correct
7 Correct 968 ms 44260 KB Output is correct
8 Correct 1000 ms 44280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 7416 KB Output is correct
2 Correct 319 ms 21000 KB Output is correct
3 Correct 1314 ms 44408 KB Output is correct
4 Correct 1938 ms 44304 KB Output is correct
5 Correct 1345 ms 43296 KB Output is correct
6 Correct 463 ms 27600 KB Output is correct
7 Correct 250 ms 18936 KB Output is correct
8 Correct 74 ms 9780 KB Output is correct
9 Correct 1457 ms 44392 KB Output is correct
10 Correct 1020 ms 44336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1351 ms 44152 KB Output is correct
2 Correct 2133 ms 44152 KB Output is correct
3 Correct 641 ms 43688 KB Output is correct
4 Correct 1597 ms 44252 KB Output is correct
5 Correct 1517 ms 44124 KB Output is correct
6 Correct 616 ms 43512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 7416 KB Output is correct
2 Correct 13 ms 7416 KB Output is correct
3 Correct 13 ms 7416 KB Output is correct
4 Correct 17 ms 7416 KB Output is correct
5 Correct 10 ms 7416 KB Output is correct
6 Correct 11 ms 7416 KB Output is correct
7 Correct 11 ms 7416 KB Output is correct
8 Correct 9 ms 7416 KB Output is correct
9 Correct 12 ms 7428 KB Output is correct
10 Correct 11 ms 7416 KB Output is correct
11 Correct 22 ms 7416 KB Output is correct
12 Correct 22 ms 7416 KB Output is correct
13 Correct 21 ms 7416 KB Output is correct
14 Correct 20 ms 7416 KB Output is correct
15 Correct 23 ms 7416 KB Output is correct
16 Correct 15 ms 7544 KB Output is correct
17 Correct 12 ms 7544 KB Output is correct
18 Correct 11 ms 7544 KB Output is correct
19 Correct 13 ms 8184 KB Output is correct
20 Correct 16 ms 8060 KB Output is correct
21 Correct 21 ms 8184 KB Output is correct
22 Correct 39 ms 8184 KB Output is correct
23 Correct 43 ms 8056 KB Output is correct
24 Correct 40 ms 8060 KB Output is correct
25 Correct 39 ms 8060 KB Output is correct
26 Correct 42 ms 8056 KB Output is correct
27 Correct 24 ms 8824 KB Output is correct
28 Correct 20 ms 8824 KB Output is correct
29 Correct 19 ms 8952 KB Output is correct
30 Correct 51 ms 8828 KB Output is correct
31 Correct 51 ms 8828 KB Output is correct
32 Correct 53 ms 8796 KB Output is correct
33 Correct 94 ms 20984 KB Output is correct
34 Correct 95 ms 20984 KB Output is correct
35 Correct 125 ms 21044 KB Output is correct
36 Correct 561 ms 20984 KB Output is correct
37 Correct 397 ms 21112 KB Output is correct
38 Correct 344 ms 21112 KB Output is correct
39 Correct 368 ms 19960 KB Output is correct
40 Correct 379 ms 19960 KB Output is correct
41 Correct 475 ms 20088 KB Output is correct
42 Correct 355 ms 20600 KB Output is correct
43 Correct 341 ms 21112 KB Output is correct
44 Correct 413 ms 21116 KB Output is correct
45 Correct 363 ms 21112 KB Output is correct
46 Correct 367 ms 21104 KB Output is correct
47 Correct 476 ms 20984 KB Output is correct
48 Correct 368 ms 20984 KB Output is correct
49 Correct 380 ms 21112 KB Output is correct
50 Correct 359 ms 21032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 7416 KB Output is correct
2 Correct 13 ms 7416 KB Output is correct
3 Correct 13 ms 7416 KB Output is correct
4 Correct 17 ms 7416 KB Output is correct
5 Correct 10 ms 7416 KB Output is correct
6 Correct 11 ms 7416 KB Output is correct
7 Correct 11 ms 7416 KB Output is correct
8 Correct 9 ms 7416 KB Output is correct
9 Correct 12 ms 7428 KB Output is correct
10 Correct 11 ms 7416 KB Output is correct
11 Correct 22 ms 7416 KB Output is correct
12 Correct 22 ms 7416 KB Output is correct
13 Correct 21 ms 7416 KB Output is correct
14 Correct 20 ms 7416 KB Output is correct
15 Correct 23 ms 7416 KB Output is correct
16 Correct 15 ms 7544 KB Output is correct
17 Correct 12 ms 7544 KB Output is correct
18 Correct 11 ms 7544 KB Output is correct
19 Correct 13 ms 8184 KB Output is correct
20 Correct 16 ms 8060 KB Output is correct
21 Correct 21 ms 8184 KB Output is correct
22 Correct 39 ms 8184 KB Output is correct
23 Correct 43 ms 8056 KB Output is correct
24 Correct 40 ms 8060 KB Output is correct
25 Correct 39 ms 8060 KB Output is correct
26 Correct 42 ms 8056 KB Output is correct
27 Correct 275 ms 44280 KB Output is correct
28 Correct 322 ms 45664 KB Output is correct
29 Correct 305 ms 45516 KB Output is correct
30 Correct 254 ms 45668 KB Output is correct
31 Correct 945 ms 44152 KB Output is correct
32 Correct 1362 ms 44512 KB Output is correct
33 Correct 968 ms 44260 KB Output is correct
34 Correct 1000 ms 44280 KB Output is correct
35 Correct 14 ms 7416 KB Output is correct
36 Correct 319 ms 21000 KB Output is correct
37 Correct 1314 ms 44408 KB Output is correct
38 Correct 1938 ms 44304 KB Output is correct
39 Correct 1345 ms 43296 KB Output is correct
40 Correct 463 ms 27600 KB Output is correct
41 Correct 250 ms 18936 KB Output is correct
42 Correct 74 ms 9780 KB Output is correct
43 Correct 1457 ms 44392 KB Output is correct
44 Correct 1020 ms 44336 KB Output is correct
45 Correct 1351 ms 44152 KB Output is correct
46 Correct 2133 ms 44152 KB Output is correct
47 Correct 641 ms 43688 KB Output is correct
48 Correct 1597 ms 44252 KB Output is correct
49 Correct 1517 ms 44124 KB Output is correct
50 Correct 616 ms 43512 KB Output is correct
51 Correct 24 ms 8824 KB Output is correct
52 Correct 20 ms 8824 KB Output is correct
53 Correct 19 ms 8952 KB Output is correct
54 Correct 51 ms 8828 KB Output is correct
55 Correct 51 ms 8828 KB Output is correct
56 Correct 53 ms 8796 KB Output is correct
57 Correct 94 ms 20984 KB Output is correct
58 Correct 95 ms 20984 KB Output is correct
59 Correct 125 ms 21044 KB Output is correct
60 Correct 561 ms 20984 KB Output is correct
61 Correct 397 ms 21112 KB Output is correct
62 Correct 344 ms 21112 KB Output is correct
63 Correct 368 ms 19960 KB Output is correct
64 Correct 379 ms 19960 KB Output is correct
65 Correct 475 ms 20088 KB Output is correct
66 Correct 355 ms 20600 KB Output is correct
67 Correct 341 ms 21112 KB Output is correct
68 Correct 413 ms 21116 KB Output is correct
69 Correct 363 ms 21112 KB Output is correct
70 Correct 367 ms 21104 KB Output is correct
71 Correct 476 ms 20984 KB Output is correct
72 Correct 368 ms 20984 KB Output is correct
73 Correct 380 ms 21112 KB Output is correct
74 Correct 359 ms 21032 KB Output is correct
75 Correct 312 ms 44152 KB Output is correct
76 Correct 357 ms 44372 KB Output is correct
77 Correct 313 ms 44408 KB Output is correct
78 Correct 272 ms 44144 KB Output is correct
79 Correct 513 ms 44360 KB Output is correct
80 Correct 267 ms 44152 KB Output is correct
81 Correct 1392 ms 44304 KB Output is correct
82 Correct 1417 ms 44268 KB Output is correct
83 Correct 2069 ms 44520 KB Output is correct
84 Correct 1409 ms 44272 KB Output is correct
85 Correct 1378 ms 44152 KB Output is correct
86 Correct 1372 ms 44164 KB Output is correct
87 Correct 1734 ms 44252 KB Output is correct
88 Correct 1263 ms 44024 KB Output is correct
89 Correct 1398 ms 43880 KB Output is correct
90 Correct 1359 ms 43896 KB Output is correct
91 Correct 1321 ms 43884 KB Output is correct
92 Correct 1228 ms 44040 KB Output is correct
93 Correct 1933 ms 44008 KB Output is correct
94 Execution timed out 3105 ms 42104 KB Time limit exceeded
95 Halted 0 ms 0 KB -