#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 301010
#define INF 1000000010
pair<pair<int, int>, pair<int, int>> in[MAX];
int X[MAX];
int Y[MAX];
int R[MAX];
int ind[MAX];
int ri[MAX];
int ans[MAX];
inline ll sq(ll x)
{
return x * x;
}
inline bool check(int i, int j)
{
return sq(X[i] - X[j]) + sq(Y[i] - Y[j]) <= sq(R[i] + R[j]);
}
bool isrange(int x, int y)
{
if (x < 0 || y < 0)
{
return false;
}
return true;
}
inline ll trans(int x, int y)
{
return ((ll)x * (ll)INF) + y;
}
bool cmp(pair<pair<int, int>, pair<int, int>>& p1, pair<pair<int, int>, pair<int, int>>& p2)
{
if (p1.first.first == p2.first.first)
{
return p1.first.second < p2.first.second;
}
else
{
return p1.first.first > p2.first.first;
}
}
unordered_map<ll, vector<int>> mp;
signed main()
{
ios::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
int i;
for (i = 1; i <= n; i++)
{
cin >> in[i].second.first >> in[i].second.second >> in[i].first.first, in[i].first.second = i;
}
sort(in + 1, in + n + 1, cmp);
for (i = 1; i <= n; i++)
{
tie(X[i], Y[i], R[i], ind[i]) = make_tuple(in[i].second.first + INF, in[i].second.second + INF, in[i].first.first, in[i].first.second);
}
int k;
int s, e;
e = 0;
for (k = 30; k >= 0; k--)
{
int r = 1 << k;
s = e + 1;
if (R[s] < r / 2)
{
continue;
}
mp.clear();
e = 0;
for (i = s; i <= n; i++)
{
if (ans[i])
{
continue;
}
int x = X[i] >> k;
int y = Y[i] >> k;
if (R[i] < r / 2 && !e)
{
e = i - 1;
}
int xx, yy;
for (xx = x - 1; xx <= x + 1; xx++)
{
for (yy = y - 1; yy <= y + 1; yy++)
{
mp[((ll)xx << 31LL) + yy].push_back(i);
}
}
}
if (e == 0)
{
e = n;
}
for (i = s; i <= e; i++)
{
if (ans[i])
{
continue;
}
ans[i] = i;
int x, y;
x = X[i] >> k;
y = Y[i] >> k;
int xx, yy;
for (xx = x - 1; xx <= x + 1; xx++)
{
for (yy = y - 1; yy <= y + 1; yy++)
{
ll t = ((ll)xx << 31LL) + yy;
for (auto c : mp[t])
{
if (!ans[c] && check(c, i))
{
ans[c] = i;
}
}
}
}
}
}
for (i = 1; i <= n; i++)
{
ri[ind[i]] = i;
}
for (i = 1; i <= n; i++)
{
cout << ind[ans[ri[i]]] << ' ';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
724 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
21 |
Correct |
4 ms |
852 KB |
Output is correct |
22 |
Correct |
19 ms |
4784 KB |
Output is correct |
23 |
Correct |
27 ms |
4784 KB |
Output is correct |
24 |
Correct |
25 ms |
4784 KB |
Output is correct |
25 |
Correct |
18 ms |
4756 KB |
Output is correct |
26 |
Correct |
20 ms |
4784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
210 ms |
22152 KB |
Output is correct |
2 |
Correct |
222 ms |
22200 KB |
Output is correct |
3 |
Correct |
203 ms |
22232 KB |
Output is correct |
4 |
Correct |
234 ms |
21756 KB |
Output is correct |
5 |
Correct |
319 ms |
33804 KB |
Output is correct |
6 |
Correct |
1610 ms |
65064 KB |
Output is correct |
7 |
Correct |
374 ms |
32184 KB |
Output is correct |
8 |
Correct |
670 ms |
40008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
991 ms |
84464 KB |
Output is correct |
3 |
Correct |
2807 ms |
247204 KB |
Output is correct |
4 |
Correct |
2877 ms |
247144 KB |
Output is correct |
5 |
Execution timed out |
3080 ms |
162924 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1397 ms |
248264 KB |
Output is correct |
2 |
Correct |
1503 ms |
248484 KB |
Output is correct |
3 |
Correct |
608 ms |
37268 KB |
Output is correct |
4 |
Correct |
1467 ms |
248360 KB |
Output is correct |
5 |
Correct |
1451 ms |
248440 KB |
Output is correct |
6 |
Correct |
320 ms |
31972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
724 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
21 |
Correct |
4 ms |
852 KB |
Output is correct |
22 |
Correct |
19 ms |
4784 KB |
Output is correct |
23 |
Correct |
27 ms |
4784 KB |
Output is correct |
24 |
Correct |
25 ms |
4784 KB |
Output is correct |
25 |
Correct |
18 ms |
4756 KB |
Output is correct |
26 |
Correct |
20 ms |
4784 KB |
Output is correct |
27 |
Correct |
8 ms |
1236 KB |
Output is correct |
28 |
Correct |
9 ms |
1276 KB |
Output is correct |
29 |
Correct |
8 ms |
1108 KB |
Output is correct |
30 |
Correct |
39 ms |
9316 KB |
Output is correct |
31 |
Correct |
55 ms |
9316 KB |
Output is correct |
32 |
Correct |
69 ms |
9316 KB |
Output is correct |
33 |
Correct |
69 ms |
7516 KB |
Output is correct |
34 |
Correct |
70 ms |
7524 KB |
Output is correct |
35 |
Correct |
72 ms |
7832 KB |
Output is correct |
36 |
Correct |
1058 ms |
86544 KB |
Output is correct |
37 |
Correct |
985 ms |
86556 KB |
Output is correct |
38 |
Correct |
1076 ms |
86412 KB |
Output is correct |
39 |
Correct |
731 ms |
17764 KB |
Output is correct |
40 |
Correct |
680 ms |
17652 KB |
Output is correct |
41 |
Correct |
678 ms |
17668 KB |
Output is correct |
42 |
Correct |
188 ms |
15252 KB |
Output is correct |
43 |
Correct |
444 ms |
81712 KB |
Output is correct |
44 |
Correct |
669 ms |
81728 KB |
Output is correct |
45 |
Correct |
444 ms |
81700 KB |
Output is correct |
46 |
Correct |
461 ms |
81772 KB |
Output is correct |
47 |
Correct |
438 ms |
81760 KB |
Output is correct |
48 |
Correct |
448 ms |
81728 KB |
Output is correct |
49 |
Correct |
476 ms |
81912 KB |
Output is correct |
50 |
Correct |
454 ms |
81780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
6 ms |
724 KB |
Output is correct |
20 |
Correct |
4 ms |
724 KB |
Output is correct |
21 |
Correct |
4 ms |
852 KB |
Output is correct |
22 |
Correct |
19 ms |
4784 KB |
Output is correct |
23 |
Correct |
27 ms |
4784 KB |
Output is correct |
24 |
Correct |
25 ms |
4784 KB |
Output is correct |
25 |
Correct |
18 ms |
4756 KB |
Output is correct |
26 |
Correct |
20 ms |
4784 KB |
Output is correct |
27 |
Correct |
210 ms |
22152 KB |
Output is correct |
28 |
Correct |
222 ms |
22200 KB |
Output is correct |
29 |
Correct |
203 ms |
22232 KB |
Output is correct |
30 |
Correct |
234 ms |
21756 KB |
Output is correct |
31 |
Correct |
319 ms |
33804 KB |
Output is correct |
32 |
Correct |
1610 ms |
65064 KB |
Output is correct |
33 |
Correct |
374 ms |
32184 KB |
Output is correct |
34 |
Correct |
670 ms |
40008 KB |
Output is correct |
35 |
Correct |
0 ms |
340 KB |
Output is correct |
36 |
Correct |
991 ms |
84464 KB |
Output is correct |
37 |
Correct |
2807 ms |
247204 KB |
Output is correct |
38 |
Correct |
2877 ms |
247144 KB |
Output is correct |
39 |
Execution timed out |
3080 ms |
162924 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |