SGU 119 Beautiful People
来源:互联网 发布:tvb电视台直播软件 编辑:程序博客网 时间:2024/05/15 19:05
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define maxx 100050struct node{ int a,b,id;}g[maxx];int root[maxx];int id[maxx];int len;void output(int x){ if(x==-1)return; output(root[x]); printf("%d ",g[x].id);}int cmp (node x,node y){ if(x.a!=y.a) return x.a<y.a; return x.b>y.b;}int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d%d",&g[i].a,&g[i].b); g[i].id=i; } sort(g+1,g+n+1,cmp); int len=1; int l,r; id[0]=1; memset(root,-1,sizeof(root)); for(int i=2;i<=n;i++) { if(g[i].b>g[id[len-1]].b) { id[len++]=i; root[i]=id[len-2]; continue; } l=0; r=len-1; while(l<r) { int mid=(l+r)>>1; if(g[i].b>g[id[mid]].b) l=mid+1; else r=mid; } id[l]=i; if(l==0) root[l]=-1; else root[i]=id[l-1]; } printf("%d\n",len); output(id[len-1]); puts("");}
0 0
- SGU 119 Beautiful People
- sgu 199 Beautiful People
- SGU--199 beautiful people
- SGU 199 Beautiful People
- sgu 199 Beautiful People dp
- SGU 199. Beautiful People 二维LIS
- ZOJ Problem Set - 2319 Beautiful People || sgu 199
- SGU 199 Beautiful People lis O(nlogn)算法
- Beautiful People
- sgu 199 Beautiful People (DP-LIS O(nlogn)算法 输出所选元素)
- sgu 199 beautiful people(nlog 的LIS并输出路径)
- SGU 199. Beautiful People(最长上升子序列nlogn LIS)
- zoj 3519 Beautiful People
- ZOJ 2319 Beautiful People
- ZOJ 2319 Beautiful People
- zoj 2319 Beautiful People
- ACdream 1216 Beautiful People
- Beautiful People (zoj 2319)
- c++调用Libsvm
- 第一天来、希望能学到东西……
- HDU--3790:最短路径问题 (Dijkstra算法)
- Unity3D 通过 shader 实现流光效果
- cuda总结(转)
- SGU 119 Beautiful People
- SDET的职位描述
- C++之多态性与虚函数
- 马尔可夫链
- 展讯平台-sensor驱动
- select详解
- How to Write a Project Proposal
- openstack之存储
- 判断java对象是否死亡