#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
#define int long long
using namespace std;
typedef pair<int,int> pii;
pii operator+(pii a,pii b){
return {a.fs+b.fs,a.sc+b.sc};
}
pii operator-(pii a,pii b){
return {a.fs-b.fs,a.sc-b.sc};
}
int dot(pii a,pii b){
return a.fs*b.fs+a.sc*b.sc;
}
int cross(pii a,pii b){
return a.fs*b.sc-b.fs*a.sc;
}
int dis(pii a,pii b){
return dot(a-b,a-b);
}
signed main(){
AquA;
int n;
cin >> n;
vector<pair<pii,int> > vp(n);
vector<pii> g;
vector<int> from(n,-1);
set<pii> sl,sr;
vector<int> l(n),r(n);
for(int i=0;i<n;i++){
cin >> vp[i].fs.fs >> vp[i].fs.sc >> vp[i].sc;
g.push_back({-vp[i].sc,i});
l[i]=vp[i].fs.fs-vp[i].sc;
r[i]=vp[i].fs.fs+vp[i].sc;
sl.insert({l[i],i});
sr.insert({r[i],i});
}
sort(g.begin(),g.end());
for(int k=0;k<n;k++){
int i=g[k].sc;
if(from[i]>=0){
continue;
}
for(auto it=sl.lower_bound(pii(l[i],-1));it!=sl.end();it=sl.erase(it)){
if(it->fs>r[i]){
break;
}
from[it->sc]=i;
sr.erase(pii(r[it->sc],it->sc));
}
for(auto it=sr.lower_bound(pii(l[i],-1));it!=sr.end();it=sr.erase(it)){
if(it->fs>r[i]){
break;
}
from[it->sc]=i;
sl.erase(pii(l[it->sc],it->sc));
}
}
for(int i=0;i<n;i++){
cout << from[i]+1 << " ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
821 ms |
58780 KB |
Output is correct |
2 |
Correct |
816 ms |
58792 KB |
Output is correct |
3 |
Correct |
789 ms |
58476 KB |
Output is correct |
4 |
Correct |
823 ms |
58796 KB |
Output is correct |
5 |
Correct |
677 ms |
58512 KB |
Output is correct |
6 |
Correct |
676 ms |
63264 KB |
Output is correct |
7 |
Correct |
653 ms |
63564 KB |
Output is correct |
8 |
Correct |
626 ms |
63272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
525 ms |
58356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |