#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <vector>
#define int long long
using namespace std;
unordered_map<int, vector<int>>x;
vector<pair<int, int>>po;
vector<pair<int, int>>so;
int pre[300100];
int num[300100];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
int i;
for (i = 0; i < N; i++)
{
int a, b, c;
cin >> a >> b >> c;
a += 1LL << 30;
b += 1LL << 30;
pre[i] = c;
so.push_back({ -c,i });
po.push_back({ a,b });
}
sort(so.begin(), so.end());
int gr = 30;
for (i = 0; i < N; i++)
{
x[po[i].first / (1LL << gr)*(1LL<<31)+ po[i].second / (1LL << gr)].push_back(i);
}
for (i = 0; i < N; i++)
{
if (num[so[i].second])
continue;
while ((1LL << gr) >= -so[i].first*2)
{
gr--;
x.clear();
int i;
for (i = 0; i < N; i++)
{
x[po[i].first / (1LL << gr) * (1LL << 31) + po[i].second / (1LL << gr)].push_back(i);
}
}
int xx = po[so[i].second].first / (1LL << gr);
int y = po[so[i].second].second / (1LL << gr);
int j, k;
for (j = xx - 2; j <= xx + 2; j++)
{
for (k = y - 2; k <= y + 2; k++)
{
if (!x.count(j * (1LL << 31) + k))
continue;
int l;
for (l = 0; l < x[j*(1LL<<31)+ k].size(); l++)
{
int le = x[j * (1LL << 31)+ k][l];
if (num[le])
continue;
if ((po[so[i].second].first - po[le].first) * (po[so[i].second].first - po[le].first) + (po[so[i].second].second - po[le].second) * (po[so[i].second].second - po[le].second) <= (-so[i].first + pre[le]) * (-so[i].first + pre[le]))
{
num[le] = so[i].second+1;
}
}
}
}
}
for (i = 0; i < N; i++)
{
cout << num[i] << ' ';
}
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:59:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | for (l = 0; l < x[j*(1LL<<31)+ k].size(); l++)
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
460 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
716 KB |
Output is correct |
20 |
Correct |
5 ms |
716 KB |
Output is correct |
21 |
Correct |
7 ms |
844 KB |
Output is correct |
22 |
Correct |
26 ms |
1080 KB |
Output is correct |
23 |
Correct |
29 ms |
996 KB |
Output is correct |
24 |
Correct |
29 ms |
1084 KB |
Output is correct |
25 |
Correct |
29 ms |
1076 KB |
Output is correct |
26 |
Correct |
26 ms |
1064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
21308 KB |
Output is correct |
2 |
Correct |
250 ms |
21184 KB |
Output is correct |
3 |
Correct |
223 ms |
20616 KB |
Output is correct |
4 |
Correct |
238 ms |
20240 KB |
Output is correct |
5 |
Correct |
1102 ms |
35436 KB |
Output is correct |
6 |
Correct |
2330 ms |
42676 KB |
Output is correct |
7 |
Correct |
1584 ms |
41556 KB |
Output is correct |
8 |
Correct |
1753 ms |
41952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1091 ms |
14952 KB |
Output is correct |
3 |
Execution timed out |
3085 ms |
40940 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2717 ms |
42980 KB |
Output is correct |
2 |
Execution timed out |
3010 ms |
45628 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
460 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
716 KB |
Output is correct |
20 |
Correct |
5 ms |
716 KB |
Output is correct |
21 |
Correct |
7 ms |
844 KB |
Output is correct |
22 |
Correct |
26 ms |
1080 KB |
Output is correct |
23 |
Correct |
29 ms |
996 KB |
Output is correct |
24 |
Correct |
29 ms |
1084 KB |
Output is correct |
25 |
Correct |
29 ms |
1076 KB |
Output is correct |
26 |
Correct |
26 ms |
1064 KB |
Output is correct |
27 |
Correct |
16 ms |
1676 KB |
Output is correct |
28 |
Correct |
8 ms |
1044 KB |
Output is correct |
29 |
Correct |
8 ms |
968 KB |
Output is correct |
30 |
Correct |
57 ms |
1688 KB |
Output is correct |
31 |
Correct |
55 ms |
1624 KB |
Output is correct |
32 |
Correct |
61 ms |
1728 KB |
Output is correct |
33 |
Correct |
68 ms |
7380 KB |
Output is correct |
34 |
Correct |
70 ms |
7396 KB |
Output is correct |
35 |
Correct |
369 ms |
14784 KB |
Output is correct |
36 |
Correct |
995 ms |
14952 KB |
Output is correct |
37 |
Correct |
1127 ms |
14952 KB |
Output is correct |
38 |
Correct |
1198 ms |
14856 KB |
Output is correct |
39 |
Correct |
600 ms |
14492 KB |
Output is correct |
40 |
Correct |
611 ms |
14536 KB |
Output is correct |
41 |
Correct |
609 ms |
14416 KB |
Output is correct |
42 |
Correct |
289 ms |
11096 KB |
Output is correct |
43 |
Correct |
477 ms |
14672 KB |
Output is correct |
44 |
Correct |
475 ms |
14604 KB |
Output is correct |
45 |
Correct |
444 ms |
14648 KB |
Output is correct |
46 |
Correct |
497 ms |
14604 KB |
Output is correct |
47 |
Correct |
480 ms |
14580 KB |
Output is correct |
48 |
Correct |
458 ms |
14616 KB |
Output is correct |
49 |
Correct |
480 ms |
14776 KB |
Output is correct |
50 |
Correct |
464 ms |
14580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
460 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
716 KB |
Output is correct |
20 |
Correct |
5 ms |
716 KB |
Output is correct |
21 |
Correct |
7 ms |
844 KB |
Output is correct |
22 |
Correct |
26 ms |
1080 KB |
Output is correct |
23 |
Correct |
29 ms |
996 KB |
Output is correct |
24 |
Correct |
29 ms |
1084 KB |
Output is correct |
25 |
Correct |
29 ms |
1076 KB |
Output is correct |
26 |
Correct |
26 ms |
1064 KB |
Output is correct |
27 |
Correct |
237 ms |
21308 KB |
Output is correct |
28 |
Correct |
250 ms |
21184 KB |
Output is correct |
29 |
Correct |
223 ms |
20616 KB |
Output is correct |
30 |
Correct |
238 ms |
20240 KB |
Output is correct |
31 |
Correct |
1102 ms |
35436 KB |
Output is correct |
32 |
Correct |
2330 ms |
42676 KB |
Output is correct |
33 |
Correct |
1584 ms |
41556 KB |
Output is correct |
34 |
Correct |
1753 ms |
41952 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1091 ms |
14952 KB |
Output is correct |
37 |
Execution timed out |
3085 ms |
40940 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |