#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=1e9;
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(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 |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1002 ms |
108764 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
108764 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
717 ms |
109044 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |