G - 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

题意:给了n个数对x,y。要求找出最长的数对。使得每一维都严格递增

思路:最长上升子序列,仅仅只是是2维的。能够先按x排序以后按顺序用线段树维护就好了

            详细维护的是,以每一个y点结尾的最大长度

            需要注意的是,当相同的第一更新x在下面y在记录后,所有查询,更新统一。由于x点是不等于所述增加的序列中可以是足够

ASC(1)G(上升时间最长的序列)的更多相关文章

  1. POJ 2533 Longest Ordered Subsequence 最长递增序列

      Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequenc ...

  2. [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列

    Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...

  3. [LeetCode] Longest Consecutive Sequence 求最长连续序列

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...

  4. lintcode: 最长连续序列

    最长连续序列 给定一个未排序的整数数组,找出最长连续序列的长度. 说明 要求你的算法复杂度为O(n) 样例 给出数组[100, 4, 200, 1, 3, 2],这个最长的连续序列是 [1, 2, 3 ...

  5. POJ 3080 Blue Jeans (多个字符串的最长公共序列,暴力比较)

    题意:给出m个字符串,找出其中的最长公共子序列,如果相同长度的有多个,输出按字母排序中的第一个. 思路:数据小,因此枚举第一个字符串的所有子字符串s,再一个个比较,是否为其它字符串的字串.判断是否为字 ...

  6. leetcode 最长连续序列 longest consecutive sequence

    转载请注明来自souldak,微博:@evagle 题目(来自leetcode): 给你一个n个数的乱序序列,O(N)找出其中最长的连续序列的长度. 例如给你[100, 4, 200, 1, 3, 2 ...

  7. uva103(最长递增序列,dag上的最长路)

    题目的意思是给定k个盒子,每个盒子的维度有n dimension 问最多有多少个盒子能够依次嵌套 但是这个嵌套的规则有点特殊,两个盒子,D = (d1,d2,...dn) ,E = (e1,e2... ...

  8. [LeetCode] Number of Longest Increasing Subsequence 最长递增序列的个数

    Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: I ...

  9. [LeetCode] Binary Tree Longest Consecutive Sequence II 二叉树最长连续序列之二

    Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree. Especia ...

随机推荐

  1. C语言中的malloc和free

    最近在研究php自定义函数的实现,其中php自定义函数在传递参数时,是放到人为的一个栈中,这个跟写C程序时,参数入栈的这个栈还不一样,其中延伸到了 malloc 以及free 有人说在free(p)后 ...

  2. poj3321

    树映射到树状数组上 非常好的题目,给了我很多启发 题目要求动态求一个棵子树的节点个数 不禁联想到了前缀和,只要我们能用一个合适的优先级表示每个顶点,那么就好做了 我们可以考虑将子树表示成区间的形式 这 ...

  3. 【转】Android中removeCallbacks失效原因

    原文网址:http://blog.sina.com.cn/s/blog_6714fba70100wtx1.html 在Android开发中会使用Handle的removeCallbacks函数,该函数 ...

  4. 【转】 Android中退出程序的提示框

    原文网址:http://blog.csdn.net/jumping_android/article/details/7571309 @Override public boolean onKeyDown ...

  5. 【转】cocos2d-x游戏开发(十四)用shader使图片背景透明

    转自:http://blog.csdn.net/dawn_moon/article/details/8631783 好吧,终于抽时间写这篇文章了. 手头上有很多人物行走图,技能特效图等,但这些图都有个 ...

  6. SharePoint中的权限体系

    转:http://blog.csdn.net/yl_99/article/details/7767053 1.MOSS中的权限结构 MOSS中的权限结构主要有三部分:网站权限,列表权限,个人权限. 网 ...

  7. unix network programming(3rd)Vol.1 [第1章]《读书笔记系列》

    文章最开头介绍了 获取时间的C/S 模型的代码, 还用了实现了IPV6的版本 unix 介绍了errno值,以及在多进程/多线程中的问题 多线程中不用全局errno,而是用返回值 处理error 详细 ...

  8. SpannableStringBuilder 和 SpannableString

    EditText:         通常用于显示文字,但有时候也需要在文字中夹杂一些图片,比如QQ中就可以使用表情图片,又比如需要的文字高亮显示等等,如何在android中也做到这样呢? 记得andr ...

  9. Can't find file: './mysql/plugin.frm' (errno: 13)[mysql数据目录迁移错位]错误解决

    大概需要4个步骤,其中第1步通过service mysql stop停止数据库,第4步通过service mysql start启动数据库. 第2步移动数据文件,不知道是否为Ubuntu智能的原因,移 ...

  10. Selenium2Library系列 keywords 之 _SelectElementKeywords 之 get_list_items(self, locator)

    def get_list_items(self, locator): """Returns the values in the select list identifie ...