#include <iostream>
#include <set>
using namespace std;
#define int long long
const int N = 3e5 + 10;
int x[N];
int y[N];
int r[N];
int erased[N];
int dist(int i,int j){
int xd = x[i] - x[j];
int yd = y[i] - y[j];
return xd * xd + yd * yd;
}
void sub1(int n){
set<pair<int,int>> s;
for (int i=1;i<=n;i++)
s.insert({-r[i],i});
while (s.size() > 0){
int i = (*begin(s)).second;
for (int j=1;j<=n;j++)
if (!erased[j] and dist(i,j) <= (r[i] + r[j]) * (r[i] + r[j])){
s.erase({-r[j],j});
erased[j] = i;
}
}
for (int i=1;i<=n;i++)
cout<<erased[i]<<' ';
cout<<'\n';
exit(0);
}
void sub2(int n){
set<pair<int,int>> s,X;
for (int i=1;i<=n;i++){
s.insert({-r[i],i});
X.insert({x[i] - r[i],i});
X.insert({x[i] + r[i],i});
X.insert({x[i],i});
}
set<int> ind;
while (s.size() > 0){
int i = (*begin(s)).second;
auto u = X.upper_bound({x[i] - r[i],0});
while (u != X.end() and (*u).first <= x[i] + r[i]){
ind.insert((*u).second);
u = next(u);
}
for (int j : ind){
erased[j] = i;
s.erase({-r[j],j});
X.erase({x[j] - r[j],j});
X.erase({x[j] + r[j],j});
X.erase({x[j],j});
}
}
for (int i=1;i<=n;i++)
cout<<erased[i]<<'\n';
exit(0);
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
for (int i=1;i<=n;i++){
cin>>x[i]>>y[i]>>r[i];
y[0] += y[i];
}
if (n <= 5000)
sub1(n);
if (y[0] == 0)
sub2(n);
}
// 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
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6628 KB |
Output is correct |
17 |
Correct |
2 ms |
6492 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
4 ms |
6748 KB |
Output is correct |
20 |
Correct |
4 ms |
6748 KB |
Output is correct |
21 |
Correct |
4 ms |
6748 KB |
Output is correct |
22 |
Correct |
37 ms |
6948 KB |
Output is correct |
23 |
Correct |
36 ms |
6968 KB |
Output is correct |
24 |
Correct |
37 ms |
6748 KB |
Output is correct |
25 |
Correct |
37 ms |
6748 KB |
Output is correct |
26 |
Correct |
37 ms |
6952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2569 ms |
101076 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Incorrect |
23 ms |
6492 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
63 ms |
7508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6628 KB |
Output is correct |
17 |
Correct |
2 ms |
6492 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
4 ms |
6748 KB |
Output is correct |
20 |
Correct |
4 ms |
6748 KB |
Output is correct |
21 |
Correct |
4 ms |
6748 KB |
Output is correct |
22 |
Correct |
37 ms |
6948 KB |
Output is correct |
23 |
Correct |
36 ms |
6968 KB |
Output is correct |
24 |
Correct |
37 ms |
6748 KB |
Output is correct |
25 |
Correct |
37 ms |
6748 KB |
Output is correct |
26 |
Correct |
37 ms |
6952 KB |
Output is correct |
27 |
Incorrect |
3 ms |
6488 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
2 ms |
6628 KB |
Output is correct |
17 |
Correct |
2 ms |
6492 KB |
Output is correct |
18 |
Correct |
2 ms |
6492 KB |
Output is correct |
19 |
Correct |
4 ms |
6748 KB |
Output is correct |
20 |
Correct |
4 ms |
6748 KB |
Output is correct |
21 |
Correct |
4 ms |
6748 KB |
Output is correct |
22 |
Correct |
37 ms |
6948 KB |
Output is correct |
23 |
Correct |
36 ms |
6968 KB |
Output is correct |
24 |
Correct |
37 ms |
6748 KB |
Output is correct |
25 |
Correct |
37 ms |
6748 KB |
Output is correct |
26 |
Correct |
37 ms |
6952 KB |
Output is correct |
27 |
Incorrect |
2569 ms |
101076 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |