Beautiful People

Time Limit: 10000/5000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)    
Special Judge

Problem Description

The most prestigious sports club in one city has exactly N members. Each of its members is strong and beautiful. More precisely, i-th member of this club (members being numbered by the time they entered the
club) has strength Si and beauty Bi. Since this is a very prestigious club, its members are very rich and therefore extraordinary people, so they often extremely hate each other. Strictly speaking, i-th member of the club Mr X hates j-th member of the club
Mr Y if Si <= Sj and Bi >= Bj or if Si >= Sj and Bi <= Bj (if both properties of Mr X are greater then corresponding properties of Mr Y, he doesn't even notice him, on the other hand, if both of his properties are less, he respects Mr Y very much).

To celebrate a new 2003 year, the administration of the club is planning to organize a party. However they are afraid that if two people who hate each other would simultaneouly attend the party, after a drink
or two they would start a fight. So no two people who hate each other should be invited. On the other hand, to keep the club prestige at the apropriate level, administration wants to invite as many people as possible.

Being the only one among administration who is not afraid of touching a computer, you are to write a program which would find out whom to invite to the party.

Input

      The first line of the input file contains integer N — the number of members of the club. (2 ≤ N ≤ 100 000). Next N lines contain two numbers each — Si and
Bi respectively (1 ≤ Si, Bi ≤
109).

Output

      On the first line of the output file print the maximum number of the people that can be invited to the party. On the second line output N integers — numbers of members to be invited in arbitrary order. If several solutions exist, output any one.

Sample Input

4
1 1
1 2
2 1
2 2

Sample Output

2
1 4

#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100001;
struct P{
int s,b,id;
}p[N]; bool cmp(P a,P b)
{
if(a.s==b.s) return a.b>b.b;
return a.s<b.s;
} int dp[N];
int pre[N];
int main()
{
int T,n,i,k,l,r,m;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d%d",&p[i].s,&p[i].b);
p[i].id=i;
}
sort(p+1,p+n+1,cmp);
dp[1] = 1,k = 1;
for(i=2;i<=n;i++)
{
if(p[i].b > p[dp[k]].b)
{
pre[i] = dp[k];
dp[++k] = i;
}
else{
l=1,r=k;
while(l<r)
{
m=(l+r)>>1;
if(p[dp[m]].b<p[i].b)l=m+1;
else r=m;
} dp[l] = i;
pre[i] = dp[l-1];
}
}
printf("%d\n",k);
i = dp[k--];
printf("%d",p[i].id);
while(k--){
i = pre[i];
printf(" %d",p[i].id);
}
puts("");
return 0;
}

心好累啊,完全不明白什么意思,这代码

版权声明:本文为博主原创文章,未经博主允许不得转载。

Beautiful People 分类: Brush Mode 2014-10-01 14:33 100人阅读 评论(0) 收藏的更多相关文章

  1. MS SQL数据批量备份还原(适用于MS SQL 2005+) 分类: SQL Server 数据库 2015-03-10 14:32 103人阅读 评论(0) 收藏

    我们知道通过Sql代理,可以实现数据库的定时备份功能:当数据库里的数据库很多时,备份一个数据库需要建立对应的定时作业,相对来说比较麻烦: 还好,微软自带的osql工具,比较实用,通过在命令行里里输入命 ...

  2. A Plug for UNIX 分类: POJ 图论 函数 2015-08-10 14:18 2人阅读 评论(0) 收藏

    A Plug for UNIX Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14786 Accepted: 4994 Desc ...

  3. NYOJ-456 邮票分你一半 AC 分类: NYOJ 2014-01-02 14:33 152人阅读 评论(0) 收藏

    #include<stdio.h> #define max(x,y) x>y?x:y int main(){ int n,x,y; scanf("%d",& ...

  4. nginx 安装手记 分类: Nginx 服务器搭建 2015-07-14 14:28 15人阅读 评论(0) 收藏

    Nginx需要依赖下面3个包 gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ ) zlib-1.2.8.tar.gz rewrite 模块需要 pcre 库 ( ...

  5. RedHat Enterprise Linux 6.4使用Centos 6 的yum源 分类: 服务器搭建 Nginx 2015-07-14 14:11 5人阅读 评论(0) 收藏

    转载自:http://blog.sina.com.cn/s/blog_50f908410101cto6.html 思路:卸载redhat自带yum,然后下载centos的yum,安装后修改配置文件 1 ...

  6. 使用Broadcast实现android组件之间的通信 分类: android 学习笔记 2015-07-09 14:16 110人阅读 评论(0) 收藏

    android组件之间的通信有多种实现方式,Broadcast就是其中一种.在activity和fragment之间的通信,broadcast用的更多本文以一个activity为例. 效果如图: 布局 ...

  7. android开发之broadcast学习笔记 分类: android 学习笔记 2015-07-19 16:33 32人阅读 评论(0) 收藏

    android中的广播用的太多了,今天稍微总结一下. 按注册方式分为两种: 1.静态注册广播: 静态注册广播就是在androidManifest.xml文件中注册广播,假设我们要实现这样一个效果,在一 ...

  8. 使用JavaScriptSerializer序列化集合、字典、数组、DataTable为JSON字符串 分类: 前端 数据格式 JSON 2014-10-30 14:08 169人阅读 评论(0) 收藏

    一.JSON简介 JSON(JavaScript Object Notation,JavaScript对象表示法)是一种轻量级的数据交换格式. JSON是"名值对"的集合.结构由大 ...

  9. vs2008 多人同时开发项目时的代码注释规范格式 分类: C#小技巧 2014-04-23 14:12 297人阅读 评论(0) 收藏

    多人同时开发一个项目,区分项目的那个窗体是谁开发的,例:下面的格式 /************************************************       模块:服务器设置   ...

随机推荐

  1. PHP-PCRE正则表达式函数

    PCRE正则表达式函数 PCRE字符类 \\b        词边界 \\d        匹配任意数字 \\s        匹配任意空白,如TAB制表符或空格 \\t        匹配一个TAB ...

  2. 《安全参考》HACKCTO-201311-11

    小编的话 “晴空一鹤排云去,便引诗情到碧宵” 11月是一个让人思绪飞扬.感慨万千的时节. 就在这时,在我们小伙伴的并肩奋战下,第十一期<安全参考>又跟大家见面了. 你还在为女朋友在购物狂欢 ...

  3. 类似桌面背景壁纸随手指滑动--第三方开源--BackgroundViewPager

    Android BackgroundViewPager在github上的项目主页是:https://github.com/MoshDev/BackgroundViewPager 下载下来即可运行

  4. seeting菜单界面形成--优化

    本文是上一篇文章的优化版: 上文链接地址:http://www.cnblogs.com/zzw1994/p/5016864.html 上文中有很多方法都是过时,并且效率不是很高,主要对JAVA代码进行 ...

  5. Android———从GitHub上下载源码的方法【Written By KillerLegend】

    首先声明,本文说的是从GitHub上下载源码而非上传源码! 1:下载tortoisegit,下载地址为: https://code.google.com/p/tortoisegit/wiki/Down ...

  6. Jquery note

    the purpose: write less. do more   写得少,做更多 jquery 基本选择器, $("p ,div ")匹配所有的P元素和DIV元素 , $(&q ...

  7. Python科学计算利器——Anaconda

    (搬运自我在SegmentFault的博客) 最近在用Python做中文自然语言处理.使用的IDE是PyCharm.PyCharm确实是Python开发之首选,但用于科学计算方面,还略有欠缺.为此我尝 ...

  8. 关于datagridview的一些操作

    1.绑定datatable时,会显示出不需要显示的列可以加datagridview.AutoGenerateColumns = false; 2.如果datagridview的某列是数值型的,有小数, ...

  9. [原创]PostgreSQL中十进制、二进制、十六进制之间的相互转换

    在PostgreSQL中,二进制.十进制.十六进制之间的转换是非常方便的,如下: 十进制转十六进制和二进制 mydb=# SELECT to_hex(10); to_hex -------- a (1 ...

  10. Go语言工程结构

    Go是一门推崇软件工程理念的编程语言. Go的代码必须放在GOPATH目录下,它应该包含三个子目录: src:用于以代码包的形式组织并保存Go源码文件.应该分为三类:库源码文件.命令源码文件.测试源码 ...