#include <bits/stdc++.h>
using namespace std;
#define v vector
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
struct Circle{
ll x, y, r, i;
};
int N;
v<Circle> C;
bool compC(Circle& a, Circle& b){
if(a.r==b.r) return a.i<b.i;
return a.r>b.r;
}
bool isect(Circle& a, Circle& b){
ll dx=a.x-b.x;
ll dy=a.y-b.y;
ll r=a.r+b.r;
return dx*dx+dy*dy <= r*r;
}
v<ll> eBy;
void sub1(){
for(int i=0; i<N; i++){
if(eBy[C[i].i]!=-1) continue;
eBy[C[i].i] = C[i].i;
for(int j=i+1; j<N; j++){
if(eBy[C[j].i]==-1 && isect(C[i], C[j])){
eBy[C[j].i] = C[i].i;
}
}
}
}
void sub2(){
set<ii> pts;
for(int i=0; i<N; i++){
pts.insert(make_pair(C[i].x-C[i].r, i));
pts.insert(make_pair(C[i].x+C[i].r, i));
}
for(int i=0; i<N; i++){
if(eBy[C[i].i]!=-1) continue;
v<int> del;
auto it = pts.lower_bound(make_pair(C[i].x-C[i].r, -1));
while(it!=pts.end() && (*it).fi<=C[i].x+C[i].r){
del.push_back((*it).se);
it++;
}
for(int ind:del){
eBy[C[ind].i] = C[i].i;
pts.erase(make_pair(C[ind].x-C[ind].r, ind));
pts.erase(make_pair(C[ind].x+C[ind].r, ind));
}
}
}
void sub3(){
}
void sub4(){
}
void full(){
}
int main(){
cin>>N;
bool s2 = true;
bool s4 = true;
for(int i=0; i<N; i++){
ll x,y,r;
cin>>x>>y>>r;
C.push_back({x,y,r,i});
s2 = s2 && y==0;
s4 = s4 && r==C[0].r;
}
sort(C.begin(), C.end(), compC);
eBy = v<ll>(N,-1);
if(N<=5000) sub1();
else if(s2) sub2();
else if(s4) sub4();
else sub3();
for(int i:eBy) cout<<i+1<<" ";
cout<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
664 KB |
Output is correct |
20 |
Correct |
5 ms |
728 KB |
Output is correct |
21 |
Correct |
6 ms |
704 KB |
Output is correct |
22 |
Correct |
24 ms |
728 KB |
Output is correct |
23 |
Correct |
24 ms |
724 KB |
Output is correct |
24 |
Correct |
25 ms |
720 KB |
Output is correct |
25 |
Correct |
24 ms |
732 KB |
Output is correct |
26 |
Correct |
29 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
889 ms |
55620 KB |
Output is correct |
2 |
Correct |
790 ms |
61988 KB |
Output is correct |
3 |
Correct |
824 ms |
62880 KB |
Output is correct |
4 |
Correct |
772 ms |
64216 KB |
Output is correct |
5 |
Correct |
666 ms |
56924 KB |
Output is correct |
6 |
Correct |
618 ms |
58268 KB |
Output is correct |
7 |
Correct |
662 ms |
56480 KB |
Output is correct |
8 |
Correct |
649 ms |
56652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
93 ms |
6332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
246 ms |
16760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
664 KB |
Output is correct |
20 |
Correct |
5 ms |
728 KB |
Output is correct |
21 |
Correct |
6 ms |
704 KB |
Output is correct |
22 |
Correct |
24 ms |
728 KB |
Output is correct |
23 |
Correct |
24 ms |
724 KB |
Output is correct |
24 |
Correct |
25 ms |
720 KB |
Output is correct |
25 |
Correct |
24 ms |
732 KB |
Output is correct |
26 |
Correct |
29 ms |
724 KB |
Output is correct |
27 |
Incorrect |
11 ms |
980 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
664 KB |
Output is correct |
20 |
Correct |
5 ms |
728 KB |
Output is correct |
21 |
Correct |
6 ms |
704 KB |
Output is correct |
22 |
Correct |
24 ms |
728 KB |
Output is correct |
23 |
Correct |
24 ms |
724 KB |
Output is correct |
24 |
Correct |
25 ms |
720 KB |
Output is correct |
25 |
Correct |
24 ms |
732 KB |
Output is correct |
26 |
Correct |
29 ms |
724 KB |
Output is correct |
27 |
Correct |
889 ms |
55620 KB |
Output is correct |
28 |
Correct |
790 ms |
61988 KB |
Output is correct |
29 |
Correct |
824 ms |
62880 KB |
Output is correct |
30 |
Correct |
772 ms |
64216 KB |
Output is correct |
31 |
Correct |
666 ms |
56924 KB |
Output is correct |
32 |
Correct |
618 ms |
58268 KB |
Output is correct |
33 |
Correct |
662 ms |
56480 KB |
Output is correct |
34 |
Correct |
649 ms |
56652 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Incorrect |
93 ms |
6332 KB |
Output isn't correct |
37 |
Halted |
0 ms |
0 KB |
- |