Uarl 1303
来源:互联网 发布:全职高手周边u盘淘宝网 编辑:程序博客网 时间:2024/05/19 13:10
PRO IS HERE
其实只是简单的贪心即可,按(x,y) 排序,然后尽量取y大的。。。
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<set>#include<queue>#include<map>using namespace std;#define PB push_back#define INS insert#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)#define nMax 101000#define bug puts("Fuck");int m,n;vector<int> ans;struct BB{int x,y,xx,yy;bool read(int &n){scanf("%d%d",&xx,&yy);if(xx == 0 && yy == 0) return false;if(yy<0 || xx>m) ;else n++;x = xx,y=yy;if(x<0) x = 0;if(y>m) y = m;return true;}bool operator < (const BB & b) const {if(x == b.x) return y < b.y;return x < b.x;}};BB a[nMax];int main(){//freopen("input.txt","r",stdin);//freopen("output.txt","w",stdout);while(~scanf("%d",&m)){n = 0;while(a[n].read(n));sort(a,a+n);//printf("n=%d\n",n);int l=0;ans.clear();for(int i=0;i<n;){if(l < a[i].x) break;int cp=-1,np;while(l >= a[i].x && i < n){ if(a[i].y > cp) cp=a[i].y,np=i; i++;}if(cp <= l) continue;ans.PB(np);l = cp;}if(l < m) printf("No solution\n");else {printf("%d\n",(int)ans.size());for(int i=0;i<ans.size();i++) {printf("%d %d\n",a[ans[i]].xx,a[ans[i]].yy);}}}return 0;}
- Uarl 1303
- UARL 1011
- 【DP】UARL 1146 Maximum Sum
- 【树直径】UARL 1145 Rope in the Labyrinth
- HDUOJ 1303
- hdu 1303
- URAL 1303
- CSU 1303
- 1303 Double
- foj 1303
- 1303:Doubles
- [BZOJ] 1303
- 1303 后续遍历
- hdu 1303 Doubles(模拟)
- SWUN 1303 - 魔法学徒
- CSU 1303: Decimal
- HDU 1303(水题)
- 1303: [CQOI2009]中位数图
- 真机调试出问题“Could not launch 'app name'”,No such file or directory 的bug解决
- Androiod 开发精要 笔记
- struts2标签处理double数据类型 精度缺失问题
- C++实现RSA加密算法
- NY106——背包问题(贪心)
- Uarl 1303
- HDOJ 4143
- HTTP协议
- Ubuntu 12.04使用文本编辑器gedit显示中文乱码解决
- 线段树(2)
- 跟我一起写 Makefile
- ServletContext
- 软件项目管理
- 离职的感想吧