#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;
multiset<pii> st;
multiset<pii> itr it;
priority_queue<pii> pq;
pii cur;
int N,X[MAX],Y[MAX],R[MAX],mark[MAX],par[MAX];
signed main()
{
ios_base::sync_with_stdio(false);
/*cin.tie(0);
cout.tie(0);*/
cin>>N;
for(int A=1;A<=N;A++)
{
cin>>X[A]>>Y[A]>>R[A];
X[A]=X[A]-R[A];
Y[A]=X[A]+R[A]+R[A];
pq.push(mp(R[A],-A));
}
for(int A=1;A<=N;A++)
{
st.insert(mp(X[A],A));
st.insert(mp(Y[A],A));
}
while(!pq.empty())
{
cur=pq.top();
pq.pop();
cur.second*=-1;
if(mark[cur.second])
continue;
par[cur.second]=cur.second;
st.erase(st.find(mp(X[cur.second],cur.second)));
st.erase(st.find(mp(Y[cur.second],cur.second)));
while(true)
{
if(st.empty())
break;
it=st.lower_bound(mp(X[cur.second],-INF));
if(it==st.end())
break;
if(X[it->second]>Y[cur.second])
break;
mark[it->second]=1;
par[it->second]=cur.second;
st.erase(it);
}
}
for(int A=1;A<=N;A++)
cout<<par[A]<<" ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
552 KB |
Output is correct |
3 |
Incorrect |
2 ms |
552 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1141 ms |
56684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
56684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1022 ms |
56684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
552 KB |
Output is correct |
3 |
Incorrect |
2 ms |
552 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
552 KB |
Output is correct |
3 |
Incorrect |
2 ms |
552 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |