你是说迅雷的笔试题吗? #include <bits/stdc++.h> using namespace std; struct Bound{ unsigned int x; unsigned int y; Bound(unsigned int _x=0,unsigned int _y=0) :x(_x),y(_y){} }; int main() { list<Bound> lst; unsigned int x,y; while(scanf("%u,%u",&x,&y)){ lst.emplace_back(x,y); if(getchar()==10) break; } lst.sort([](const Bound& a,const Bound& b){ return a.x<b.x;} ); for(auto it=++lst.begin();it!=lst.end();++it){ auto cur_it = it;//保存当前迭代器 if(cur_it->x <= (--it)->y){ cur_it->x = it->x; lst.erase(it); } it = cur_it; } for(const auto& ele:lst){ printf("%u,%u ",ele.x,ele.y); } return 0; }
点赞 评论

相关推荐

04-15 23:42
中山大学 Java
ResourceUtilization:过几天楼主就会捧着一堆offer来问牛友们该怎么选辣
点赞 评论 收藏
分享
牛客网
牛客企业服务