#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,lol,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;
lol=it->second;
st.erase(st.find(mp(X[lol],lol)));
st.erase(st.find(mp(Y[lol],lol)));
}
}
for(int A=1;A<=N;A++)
cout<<par[A]<<" ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
428 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1291 ms |
56612 KB |
Output is correct |
2 |
Correct |
1267 ms |
56612 KB |
Output is correct |
3 |
Correct |
1416 ms |
56616 KB |
Output is correct |
4 |
Correct |
1453 ms |
56824 KB |
Output is correct |
5 |
Correct |
1067 ms |
56824 KB |
Output is correct |
6 |
Correct |
1075 ms |
56824 KB |
Output is correct |
7 |
Correct |
1071 ms |
56824 KB |
Output is correct |
8 |
Correct |
1032 ms |
56824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
56824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1043 ms |
56824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
428 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
428 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |