#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;
}
//cout << it->fs << " " << it->sc << endl;
from[it->sc]=i;
sr.erase(sr.find({r[i],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;
}
//cout << it->fs << " " << it->sc << endl;
from[it->sc]=i;
sl.erase(sl.find({l[i],it->sc}));
}
}
for(int i=0;i<n;i++){
cout << from[i]+1 << " ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
648 ms |
114704 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
427 ms |
114668 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |