#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+10;
int n;
pair<int, int> a[N];
int b[N], del[N];
map<pair<int, int>, vector<int>> mp;
bool check(int i, int j){
return ((a[i].first-a[j].first)*(a[i].first-a[j].first)+(a[i].second-a[j].second)*(a[i].second-a[j].second))<=(b[i]+b[j])*(b[i]+b[j]);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int x=0;
cin >> n;
for (int i=1; i<=n; ++i){
cin >> a[i].first >> a[i].second >> b[i];
a[i].first+=1e9; a[i].second+=1e9;
x=max(x, b[i]);
}
vector<int> v(n); iota(v.begin(), v.end(), 1);
sort(v.begin(), v.end(), [&](int k, int l){
return make_pair(b[k], -k)>make_pair(b[l], -l);
});
auto build=[&](){
mp.clear();
for (int i=1; i<=n; ++i) if (!del[i]){
mp[{a[i].first/x, a[i].second/x}].push_back(i);
}
};
build();
for (int i:v){
if (del[i]) continue;
if (b[i]<=x/2){
x/=2;
build();
}
for (int j=a[i].first/x-2; j<=a[i].first/x+2; ++j){
for (int k=a[i].second/x-2; k<=a[i].second/x+2; ++k){
for (int l:mp[{j, k}]) if (!del[l] && check(i, l)) del[l]=i;
}
}
}
for (int i=1; i<=n; ++i) cout << del[i] << " \n"[i==n];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
2 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4560 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4440 KB |
Output is correct |
18 |
Correct |
1 ms |
4576 KB |
Output is correct |
19 |
Correct |
3 ms |
4700 KB |
Output is correct |
20 |
Correct |
3 ms |
4756 KB |
Output is correct |
21 |
Correct |
4 ms |
4696 KB |
Output is correct |
22 |
Correct |
26 ms |
9820 KB |
Output is correct |
23 |
Correct |
27 ms |
9816 KB |
Output is correct |
24 |
Correct |
26 ms |
9816 KB |
Output is correct |
25 |
Correct |
24 ms |
10072 KB |
Output is correct |
26 |
Correct |
25 ms |
10076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
21428 KB |
Output is correct |
2 |
Correct |
122 ms |
21428 KB |
Output is correct |
3 |
Correct |
117 ms |
23080 KB |
Output is correct |
4 |
Correct |
113 ms |
22244 KB |
Output is correct |
5 |
Correct |
170 ms |
24748 KB |
Output is correct |
6 |
Correct |
921 ms |
93520 KB |
Output is correct |
7 |
Correct |
215 ms |
29620 KB |
Output is correct |
8 |
Correct |
324 ms |
39476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1014 ms |
112704 KB |
Output is correct |
3 |
Execution timed out |
3034 ms |
332400 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3061 ms |
618224 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
2 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4560 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4440 KB |
Output is correct |
18 |
Correct |
1 ms |
4576 KB |
Output is correct |
19 |
Correct |
3 ms |
4700 KB |
Output is correct |
20 |
Correct |
3 ms |
4756 KB |
Output is correct |
21 |
Correct |
4 ms |
4696 KB |
Output is correct |
22 |
Correct |
26 ms |
9820 KB |
Output is correct |
23 |
Correct |
27 ms |
9816 KB |
Output is correct |
24 |
Correct |
26 ms |
9816 KB |
Output is correct |
25 |
Correct |
24 ms |
10072 KB |
Output is correct |
26 |
Correct |
25 ms |
10076 KB |
Output is correct |
27 |
Correct |
5 ms |
4956 KB |
Output is correct |
28 |
Correct |
5 ms |
5196 KB |
Output is correct |
29 |
Correct |
5 ms |
5208 KB |
Output is correct |
30 |
Correct |
59 ms |
15340 KB |
Output is correct |
31 |
Correct |
55 ms |
15440 KB |
Output is correct |
32 |
Correct |
53 ms |
15452 KB |
Output is correct |
33 |
Correct |
41 ms |
10716 KB |
Output is correct |
34 |
Correct |
42 ms |
10824 KB |
Output is correct |
35 |
Correct |
46 ms |
10060 KB |
Output is correct |
36 |
Correct |
914 ms |
114764 KB |
Output is correct |
37 |
Correct |
923 ms |
114180 KB |
Output is correct |
38 |
Correct |
958 ms |
113984 KB |
Output is correct |
39 |
Correct |
405 ms |
34992 KB |
Output is correct |
40 |
Correct |
426 ms |
35040 KB |
Output is correct |
41 |
Correct |
400 ms |
35140 KB |
Output is correct |
42 |
Correct |
140 ms |
19512 KB |
Output is correct |
43 |
Correct |
682 ms |
182688 KB |
Output is correct |
44 |
Correct |
696 ms |
182752 KB |
Output is correct |
45 |
Correct |
666 ms |
182700 KB |
Output is correct |
46 |
Correct |
669 ms |
182980 KB |
Output is correct |
47 |
Correct |
675 ms |
182968 KB |
Output is correct |
48 |
Correct |
679 ms |
182864 KB |
Output is correct |
49 |
Correct |
672 ms |
183248 KB |
Output is correct |
50 |
Correct |
661 ms |
182608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
2 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4560 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4440 KB |
Output is correct |
18 |
Correct |
1 ms |
4576 KB |
Output is correct |
19 |
Correct |
3 ms |
4700 KB |
Output is correct |
20 |
Correct |
3 ms |
4756 KB |
Output is correct |
21 |
Correct |
4 ms |
4696 KB |
Output is correct |
22 |
Correct |
26 ms |
9820 KB |
Output is correct |
23 |
Correct |
27 ms |
9816 KB |
Output is correct |
24 |
Correct |
26 ms |
9816 KB |
Output is correct |
25 |
Correct |
24 ms |
10072 KB |
Output is correct |
26 |
Correct |
25 ms |
10076 KB |
Output is correct |
27 |
Correct |
125 ms |
21428 KB |
Output is correct |
28 |
Correct |
122 ms |
21428 KB |
Output is correct |
29 |
Correct |
117 ms |
23080 KB |
Output is correct |
30 |
Correct |
113 ms |
22244 KB |
Output is correct |
31 |
Correct |
170 ms |
24748 KB |
Output is correct |
32 |
Correct |
921 ms |
93520 KB |
Output is correct |
33 |
Correct |
215 ms |
29620 KB |
Output is correct |
34 |
Correct |
324 ms |
39476 KB |
Output is correct |
35 |
Correct |
1 ms |
4444 KB |
Output is correct |
36 |
Correct |
1014 ms |
112704 KB |
Output is correct |
37 |
Execution timed out |
3034 ms |
332400 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |