https://acs.jxnu.edu.cn/problem/CF4D
描述:
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height of the (i - 1)-th envelope respectively. Chain size is the number of envelopes in the chain.
Peter决定给他来自澳大利亚的好朋友一个快乐的生日,并送给他一张贺卡。为了使他的礼物更加神秘,他决定做一个链条。链条是一系列的信封A={a1,a2,...,an},第i个信封的宽度和高度分别比第i-1个信封的宽度和高度更大。链条规模是指链条中的信封个数。
Peter wants to make the chain of the maximum size from the envelopes he has, the chain should be such, that he'll be able to put a card into it. The card fits into the chain if its width and height is lower than the width and the height of the smallest envelope in the chain respectively. It's forbidden to turn the card and the envelopes.
Peter has very many envelopes and very little time, this hard task is entrusted to you.
Peter想要做一个他拥有的信封做成的最大数链条,链条应该能够将卡片放进去。卡片放入链条中如果他的宽度和高度要比链条中的最小信封的宽度和高度要小。禁止翻转卡片和信封。
Peter有非常多的信封和非常有限的时间,这个艰巨的任务就交给你了。
输入:
The first line contains integers n, w, h (1 ≤ n ≤ 5000, 1 ≤ w, h ≤ 106) — amount of envelopes Peter has, the card width and height respectively. Then there follow n lines, each of them contains two integer numbers wi and hi — width and height of the i-th envelope (1 ≤ wi, hi ≤ 106).
第一行包含整数n,w,h (1 ≤ n ≤ 5000, 1 ≤ w, h ≤ 106)——分别表示信封的总数,卡片的宽度和高度。接下来n行,每一行包含两个整数wi和hi——信封的宽度和高度(1 ≤ wi, hi ≤ 106)。
输出:
In the first line print the maximum chain size. In the second line print the numbers of the envelopes (separated by space), forming the required chain, starting with the number of the smallest envelope. Remember, please, that the card should fit into the smallest envelope. If the chain of maximum size is not unique, print any of the answers.
If the card does not fit into any of the envelopes, print number 0 in the single line.
在第一行输出最大链条规模。在第二行输出信封的编号(用空格分隔),组成所需链条,从编号最小的信封开始。记住,卡片要放在最小的信封里。如果最大链条长度不唯一,输出任意答案。
如果信封放不进任何信封,请输出一行数字0。
样例输入:
2 1 1 2 2 2 2
样例输出:
1 1
样例输入:
3 3 3 5 4 12 11 9 8
样例输出:
3 1 3 2