#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
int N;
ll X[300005],Y[300005],R[300005];
ll A[300005],P[300005];
vector<pll> V;
ll a;
set<pll> S;
int main(){
cin>>N;
for(int i=0;i<N;i++){
cin>>X[i]>>Y[i]>>R[i];
a=max(a,Y[i]);
}
if(N<5001){
for(int i=0;i<N;i++)
V.push_back({-R[i],i});
sort(V.begin(),V.end());
for(int i=0;i<N;i++)
P[i]=V[i].second;
//for(int i=0;i<N;i++)cout<<P[i]+1<<" ";cout<<endl;
for(int i=0;i<N;i++)
for(int j=i+1;j<N;j++)
if(
(X[P[i]]-X[P[j]])*(X[P[i]]-X[P[j]])+
(Y[P[i]]-Y[P[j]])*(Y[P[i]]-Y[P[j]])<=
(R[P[i]]+R[P[j]])*(R[P[i]]+R[P[j]])
and !A[P[j]] and !A[P[i]]
)
A[P[j]]=P[i]+1;
for(int i=0;i<N;i++)
cout<<(A[i]?A[i]:(i+1))<<" "; }
else if(!a){
for(int i=0;i<N;i++)
V.push_back({-R[i],i});
sort(V.begin(),V.end());
for(int i=0;i<N;i++){
S.insert({X[i]+R[i],i});
S.insert({X[i]-R[i],i});
P[i]=V[i].second;
}
for(int j=0;j<N;j++){
int i=P[j];
if(S.count({X[i]-R[i],i}))
for(auto p=S.lower_bound({X[i]-R[i],-1});p!=S.lower_bound({X[i]+R[i]+1,-1});){
int q=p->second;
A[q]=i+1;
if(p==S.find({X[q]-R[q],q}))
p++;
S.erase(S.find({X[q]-R[q],q}));
if(p==S.find({X[q]+R[q],q}))
p++;
S.erase(S.find({X[q]+R[q],q}));
}
}
for(int i=0;i<N;i++)
cout<<A[i]<<" ";}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
7 ms |
504 KB |
Output is correct |
17 |
Correct |
7 ms |
376 KB |
Output is correct |
18 |
Correct |
6 ms |
376 KB |
Output is correct |
19 |
Correct |
65 ms |
760 KB |
Output is correct |
20 |
Correct |
60 ms |
812 KB |
Output is correct |
21 |
Correct |
112 ms |
760 KB |
Output is correct |
22 |
Correct |
49 ms |
760 KB |
Output is correct |
23 |
Correct |
49 ms |
760 KB |
Output is correct |
24 |
Correct |
53 ms |
888 KB |
Output is correct |
25 |
Correct |
47 ms |
760 KB |
Output is correct |
26 |
Correct |
48 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1644 ms |
56600 KB |
Output is correct |
2 |
Correct |
1704 ms |
56512 KB |
Output is correct |
3 |
Correct |
1682 ms |
56304 KB |
Output is correct |
4 |
Correct |
1688 ms |
56440 KB |
Output is correct |
5 |
Correct |
1456 ms |
56184 KB |
Output is correct |
6 |
Correct |
1534 ms |
56424 KB |
Output is correct |
7 |
Correct |
1452 ms |
56352 KB |
Output is correct |
8 |
Correct |
1433 ms |
56472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
219 ms |
2620 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1543 ms |
56052 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
7 ms |
504 KB |
Output is correct |
17 |
Correct |
7 ms |
376 KB |
Output is correct |
18 |
Correct |
6 ms |
376 KB |
Output is correct |
19 |
Correct |
65 ms |
760 KB |
Output is correct |
20 |
Correct |
60 ms |
812 KB |
Output is correct |
21 |
Correct |
112 ms |
760 KB |
Output is correct |
22 |
Correct |
49 ms |
760 KB |
Output is correct |
23 |
Correct |
49 ms |
760 KB |
Output is correct |
24 |
Correct |
53 ms |
888 KB |
Output is correct |
25 |
Correct |
47 ms |
760 KB |
Output is correct |
26 |
Correct |
48 ms |
760 KB |
Output is correct |
27 |
Incorrect |
26 ms |
632 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
7 ms |
504 KB |
Output is correct |
17 |
Correct |
7 ms |
376 KB |
Output is correct |
18 |
Correct |
6 ms |
376 KB |
Output is correct |
19 |
Correct |
65 ms |
760 KB |
Output is correct |
20 |
Correct |
60 ms |
812 KB |
Output is correct |
21 |
Correct |
112 ms |
760 KB |
Output is correct |
22 |
Correct |
49 ms |
760 KB |
Output is correct |
23 |
Correct |
49 ms |
760 KB |
Output is correct |
24 |
Correct |
53 ms |
888 KB |
Output is correct |
25 |
Correct |
47 ms |
760 KB |
Output is correct |
26 |
Correct |
48 ms |
760 KB |
Output is correct |
27 |
Correct |
1644 ms |
56600 KB |
Output is correct |
28 |
Correct |
1704 ms |
56512 KB |
Output is correct |
29 |
Correct |
1682 ms |
56304 KB |
Output is correct |
30 |
Correct |
1688 ms |
56440 KB |
Output is correct |
31 |
Correct |
1456 ms |
56184 KB |
Output is correct |
32 |
Correct |
1534 ms |
56424 KB |
Output is correct |
33 |
Correct |
1452 ms |
56352 KB |
Output is correct |
34 |
Correct |
1433 ms |
56472 KB |
Output is correct |
35 |
Correct |
2 ms |
376 KB |
Output is correct |
36 |
Incorrect |
219 ms |
2620 KB |
Output isn't correct |
37 |
Halted |
0 ms |
0 KB |
- |