Mysterious Present(翻译)

2022.1.22

题目网址:

https://acs.jxnu.edu.cn/problem/CF4D

原题:

Mysterious Present

 1000ms  65536K

描述:

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

输入:

The first line contains integers nwh (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).

输出:

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.

翻译:

描述:

彼得决定为他来自澳大利亚的朋友庆祝生日并送他一张贺卡。为了使他的礼物更加神秘,他决定制作一个链。链上信封的顺序是A={a1,a2,...,an},第i个信封的宽度和长度比第i-1个信封的要高。链的大小是链中的信封的数量。

彼得想从这些他有的信封中做出最大的链,是他将能够把一张贺卡放入其中的链。如果这个链的宽度和长度比链中的最小信封的宽度和长度还小,那么这张贺卡就能放进链中。禁止翻看贺卡和信封。

彼得有许多的信封和非常短的时间,这个艰巨的任务就交给你了。

输入:

第一行包括整数n,w,h(1<=n<=5000,1<=w,h<=106)---分别是彼得所拥有的信封数量,贺卡的宽度和长度。然后接下来的n行,每行包括两个整数wi和hi---是第i个信封的宽度和长度(1<=wi,hi<=106)。

输出:

第一行打印出最大的链的大小。第二行打印出形成所需要的链的信封的数量(分开打印),从最小的信封的数量开始打印。请记得,贺卡应该能放进最小的信封里。如果这个链的最大尺寸不是唯一的,那么打印出其中任何一个答案就可以了。

如果贺卡无法放进任何一个信封里,那么打印单独的一行,打印一个数字0即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值