#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=4e5;
const int INF=1e12;
vector< pair<int,pii> > vec;
set<pii> st;
set<pii> itr it,it2;
int N,ind,X[MAX],Y[MAX],R[MAX],par[MAX];
void ok(int F,int S)
{
if((X[F]-X[S])*(X[F]-X[S])+(Y[F]-Y[S])*(Y[F]-Y[S])>(R[F]+R[S])*(R[F]+R[S]))
return ;
if(R[F]==R[S] and F>S)
swap(F,S);
if(R[F]>R[S])
swap(F,S);
par[F]=S;
return ;
}
bool cmp(pair<int,pii> F,pair<int,pii> S)
{
if(F.first!=S.first)
return F.first<S.first;
if(F.second.first!=S.second.first)
return F.second.first<S.second.first;
int ind=F.second.second,ind2=S.second.second;
return X[ind]<X[ind2];
}
signed main()
{
ios_base::sync_with_stdio(false);
/*cin.tie(0);
cout.tie(0);*/
cin>>N;
for(int A=1;A<=N;A++)
{
par[A]=A;
cin>>X[A]>>Y[A]>>R[A];
vec.pb(mp(Y[A]-R[A],mp(0,A)));
vec.pb(mp(Y[A]+R[A],mp(1,A)));
}
for(int A=1;A<=N;A++)
for(int B=A+1;B<=N;B++)
ok(A,B);
sort(vec.begin(),vec.end(),cmp);
for(int A=0;A<vec.size();A++)
{
ind=vec[A].second.second;
if(vec[A].second.first==0)
{
st.insert(mp(X[ind],ind));
/*it=st.find(mp(X[ind],ind));
it++;
if(it!=st.end())
ok(ind,it->second);
it--;
if(it!=st.begin())
{
it--;
ok(ind,it->second);
}*/
}
else
{
/*it=st.find(mp(X[ind],ind));
it2=it;
it2++;
if(it2!=st.end() and it!=st.begin())
{
it--;
ok(it->second,it2->second);
}*/
st.erase(mp(X[ind],ind));
}
int pre=0;
for(auto A:st)
{
if(pre)
ok(pre,A.second);
pre=A.second;
}
}
for(int A=1;A<=N;A++)
cout<<par[A]<<" ";
return 0;
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:61:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int A=0;A<vec.size();A++)
~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
540 KB |
Output is correct |
4 |
Correct |
2 ms |
540 KB |
Output is correct |
5 |
Incorrect |
2 ms |
540 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3044 ms |
33444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
33444 KB |
Output is correct |
2 |
Execution timed out |
3041 ms |
33444 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3062 ms |
33492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
540 KB |
Output is correct |
4 |
Correct |
2 ms |
540 KB |
Output is correct |
5 |
Incorrect |
2 ms |
540 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
540 KB |
Output is correct |
4 |
Correct |
2 ms |
540 KB |
Output is correct |
5 |
Incorrect |
2 ms |
540 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |