답안 #124219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124219 2019-07-02T18:49:39 Z tutis 원 고르기 (APIO18_circle_selection) C++17
100 / 100
2212 ms 51428 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;
	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);
		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 Correct 10 ms 7416 KB Output is correct
3 Correct 11 ms 7416 KB Output is correct
4 Correct 14 ms 7416 KB Output is correct
5 Correct 10 ms 7416 KB Output is correct
6 Correct 9 ms 7432 KB Output is correct
7 Correct 10 ms 7416 KB Output is correct
8 Correct 9 ms 7416 KB Output is correct
9 Correct 12 ms 7416 KB Output is correct
10 Correct 12 ms 7416 KB Output is correct
11 Correct 20 ms 7364 KB Output is correct
12 Correct 26 ms 7544 KB Output is correct
13 Correct 21 ms 7436 KB Output is correct
14 Correct 20 ms 7416 KB Output is correct
15 Correct 20 ms 7472 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 8056 KB Output is correct
20 Correct 13 ms 8056 KB Output is correct
21 Correct 19 ms 8056 KB Output is correct
22 Correct 37 ms 8056 KB Output is correct
23 Correct 46 ms 8184 KB Output is correct
24 Correct 41 ms 8056 KB Output is correct
25 Correct 39 ms 8056 KB Output is correct
26 Correct 37 ms 8056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 272 ms 42384 KB Output is correct
2 Correct 316 ms 42648 KB Output is correct
3 Correct 309 ms 42360 KB Output is correct
4 Correct 252 ms 42616 KB Output is correct
5 Correct 1061 ms 42360 KB Output is correct
6 Correct 1341 ms 42364 KB Output is correct
7 Correct 1072 ms 47136 KB Output is correct
8 Correct 1083 ms 46948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 7416 KB Output is correct
2 Correct 307 ms 19128 KB Output is correct
3 Correct 1349 ms 42344 KB Output is correct
4 Correct 1445 ms 50364 KB Output is correct
5 Correct 1461 ms 49340 KB Output is correct
6 Correct 504 ms 29816 KB Output is correct
7 Correct 261 ms 19192 KB Output is correct
8 Correct 63 ms 9720 KB Output is correct
9 Correct 1490 ms 50400 KB Output is correct
10 Correct 1166 ms 50632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1716 ms 42220 KB Output is correct
2 Correct 2212 ms 42288 KB Output is correct
3 Correct 662 ms 42016 KB Output is correct
4 Correct 1434 ms 42344 KB Output is correct
5 Correct 1806 ms 42376 KB Output is correct
6 Correct 593 ms 41768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Correct 10 ms 7416 KB Output is correct
3 Correct 11 ms 7416 KB Output is correct
4 Correct 14 ms 7416 KB Output is correct
5 Correct 10 ms 7416 KB Output is correct
6 Correct 9 ms 7432 KB Output is correct
7 Correct 10 ms 7416 KB Output is correct
8 Correct 9 ms 7416 KB Output is correct
9 Correct 12 ms 7416 KB Output is correct
10 Correct 12 ms 7416 KB Output is correct
11 Correct 20 ms 7364 KB Output is correct
12 Correct 26 ms 7544 KB Output is correct
13 Correct 21 ms 7436 KB Output is correct
14 Correct 20 ms 7416 KB Output is correct
15 Correct 20 ms 7472 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 8056 KB Output is correct
20 Correct 13 ms 8056 KB Output is correct
21 Correct 19 ms 8056 KB Output is correct
22 Correct 37 ms 8056 KB Output is correct
23 Correct 46 ms 8184 KB Output is correct
24 Correct 41 ms 8056 KB Output is correct
25 Correct 39 ms 8056 KB Output is correct
26 Correct 37 ms 8056 KB Output is correct
27 Correct 23 ms 8696 KB Output is correct
28 Correct 20 ms 8696 KB Output is correct
29 Correct 18 ms 8696 KB Output is correct
30 Correct 52 ms 8824 KB Output is correct
31 Correct 49 ms 8696 KB Output is correct
32 Correct 58 ms 8824 KB Output is correct
33 Correct 100 ms 19192 KB Output is correct
34 Correct 100 ms 19064 KB Output is correct
35 Correct 140 ms 19192 KB Output is correct
36 Correct 364 ms 19092 KB Output is correct
37 Correct 360 ms 19064 KB Output is correct
38 Correct 382 ms 19064 KB Output is correct
39 Correct 371 ms 19064 KB Output is correct
40 Correct 374 ms 19064 KB Output is correct
41 Correct 384 ms 19064 KB Output is correct
42 Correct 290 ms 19008 KB Output is correct
43 Correct 380 ms 19064 KB Output is correct
44 Correct 443 ms 19064 KB Output is correct
45 Correct 357 ms 19020 KB Output is correct
46 Correct 387 ms 19036 KB Output is correct
47 Correct 370 ms 19064 KB Output is correct
48 Correct 374 ms 19016 KB Output is correct
49 Correct 380 ms 19080 KB Output is correct
50 Correct 350 ms 19064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Correct 10 ms 7416 KB Output is correct
3 Correct 11 ms 7416 KB Output is correct
4 Correct 14 ms 7416 KB Output is correct
5 Correct 10 ms 7416 KB Output is correct
6 Correct 9 ms 7432 KB Output is correct
7 Correct 10 ms 7416 KB Output is correct
8 Correct 9 ms 7416 KB Output is correct
9 Correct 12 ms 7416 KB Output is correct
10 Correct 12 ms 7416 KB Output is correct
11 Correct 20 ms 7364 KB Output is correct
12 Correct 26 ms 7544 KB Output is correct
13 Correct 21 ms 7436 KB Output is correct
14 Correct 20 ms 7416 KB Output is correct
15 Correct 20 ms 7472 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 8056 KB Output is correct
20 Correct 13 ms 8056 KB Output is correct
21 Correct 19 ms 8056 KB Output is correct
22 Correct 37 ms 8056 KB Output is correct
23 Correct 46 ms 8184 KB Output is correct
24 Correct 41 ms 8056 KB Output is correct
25 Correct 39 ms 8056 KB Output is correct
26 Correct 37 ms 8056 KB Output is correct
27 Correct 272 ms 42384 KB Output is correct
28 Correct 316 ms 42648 KB Output is correct
29 Correct 309 ms 42360 KB Output is correct
30 Correct 252 ms 42616 KB Output is correct
31 Correct 1061 ms 42360 KB Output is correct
32 Correct 1341 ms 42364 KB Output is correct
33 Correct 1072 ms 47136 KB Output is correct
34 Correct 1083 ms 46948 KB Output is correct
35 Correct 13 ms 7416 KB Output is correct
36 Correct 307 ms 19128 KB Output is correct
37 Correct 1349 ms 42344 KB Output is correct
38 Correct 1445 ms 50364 KB Output is correct
39 Correct 1461 ms 49340 KB Output is correct
40 Correct 504 ms 29816 KB Output is correct
41 Correct 261 ms 19192 KB Output is correct
42 Correct 63 ms 9720 KB Output is correct
43 Correct 1490 ms 50400 KB Output is correct
44 Correct 1166 ms 50632 KB Output is correct
45 Correct 1716 ms 42220 KB Output is correct
46 Correct 2212 ms 42288 KB Output is correct
47 Correct 662 ms 42016 KB Output is correct
48 Correct 1434 ms 42344 KB Output is correct
49 Correct 1806 ms 42376 KB Output is correct
50 Correct 593 ms 41768 KB Output is correct
51 Correct 23 ms 8696 KB Output is correct
52 Correct 20 ms 8696 KB Output is correct
53 Correct 18 ms 8696 KB Output is correct
54 Correct 52 ms 8824 KB Output is correct
55 Correct 49 ms 8696 KB Output is correct
56 Correct 58 ms 8824 KB Output is correct
57 Correct 100 ms 19192 KB Output is correct
58 Correct 100 ms 19064 KB Output is correct
59 Correct 140 ms 19192 KB Output is correct
60 Correct 364 ms 19092 KB Output is correct
61 Correct 360 ms 19064 KB Output is correct
62 Correct 382 ms 19064 KB Output is correct
63 Correct 371 ms 19064 KB Output is correct
64 Correct 374 ms 19064 KB Output is correct
65 Correct 384 ms 19064 KB Output is correct
66 Correct 290 ms 19008 KB Output is correct
67 Correct 380 ms 19064 KB Output is correct
68 Correct 443 ms 19064 KB Output is correct
69 Correct 357 ms 19020 KB Output is correct
70 Correct 387 ms 19036 KB Output is correct
71 Correct 370 ms 19064 KB Output is correct
72 Correct 374 ms 19016 KB Output is correct
73 Correct 380 ms 19080 KB Output is correct
74 Correct 350 ms 19064 KB Output is correct
75 Correct 311 ms 51428 KB Output is correct
76 Correct 406 ms 51160 KB Output is correct
77 Correct 332 ms 51336 KB Output is correct
78 Correct 290 ms 51148 KB Output is correct
79 Correct 720 ms 50976 KB Output is correct
80 Correct 280 ms 51064 KB Output is correct
81 Correct 1574 ms 50296 KB Output is correct
82 Correct 1664 ms 50104 KB Output is correct
83 Correct 2029 ms 50036 KB Output is correct
84 Correct 1388 ms 50680 KB Output is correct
85 Correct 1660 ms 50148 KB Output is correct
86 Correct 1477 ms 50428 KB Output is correct
87 Correct 1525 ms 50296 KB Output is correct
88 Correct 1579 ms 45560 KB Output is correct
89 Correct 1279 ms 45440 KB Output is correct
90 Correct 1280 ms 45560 KB Output is correct
91 Correct 1338 ms 45588 KB Output is correct
92 Correct 1251 ms 45560 KB Output is correct
93 Correct 1985 ms 49120 KB Output is correct
94 Correct 1819 ms 49716 KB Output is correct
95 Correct 1898 ms 49316 KB Output is correct
96 Correct 1697 ms 49208 KB Output is correct
97 Correct 2183 ms 49052 KB Output is correct
98 Correct 1296 ms 49512 KB Output is correct
99 Correct 1906 ms 49400 KB Output is correct
100 Correct 2041 ms 49144 KB Output is correct
101 Correct 1351 ms 49528 KB Output is correct
102 Correct 1756 ms 49200 KB Output is correct
103 Correct 1814 ms 49248 KB Output is correct
104 Correct 1984 ms 49124 KB Output is correct
105 Correct 1399 ms 46888 KB Output is correct
106 Correct 1402 ms 50184 KB Output is correct
107 Correct 1282 ms 50040 KB Output is correct
108 Correct 1333 ms 50140 KB Output is correct
109 Correct 1525 ms 50040 KB Output is correct
110 Correct 1466 ms 50056 KB Output is correct
111 Correct 1354 ms 50112 KB Output is correct
112 Correct 1974 ms 50008 KB Output is correct
113 Correct 1433 ms 50132 KB Output is correct
114 Correct 1571 ms 49940 KB Output is correct
115 Correct 1518 ms 49996 KB Output is correct
116 Correct 1459 ms 49912 KB Output is correct