Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct line {
- int b,e,id;
- };
- auto cmp = []( int b ,auto it)->bool {
- if( it.b > b)
- return true;
- return false;
- };
- for(int i = 0;i<l.size();++i){
- if(l[i].e >= l[i+1].e && l[i].b <= l[i+1].b ){
- line p;
- p.e = l[i].e;
- p.b = l[i+1].e+1;
- p.id = l[i].id;
- l[i].e = l[i+1].b-1;
- auto upper = std::upper_bound(l.begin(), l.end(), l[i+1].e , cmp );
- //cout<<l[i].e<<" "<<distance(l.begin()+i, upper)<<" "<< (*upper).b <<endl;
- if(p.e != p.b){
- l.emplace(l.begin()+i+distance(l.begin()+i, upper),p);
- }
- if(l[i].e < l[i].b ){
- l.erase (l.begin()+i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement