2022.01.29翻译Mysterious Present

Mysterious Present
题目(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 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 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).

输出:
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.

样例输入:
2 1 1
2 2
2 2
样例输出:
1

样例输入:
3 3 3
5 4
12 11
9 8
样例输出:
3
1 3 2 

翻译:
Peter决定给来自澳大利亚的朋友生日祝福并且送他一张贺卡。为了让他的礼物更加神秘,他决定做一个“锁链”。“锁链“是一连串的信封A = {a1,  a2,  ...,  an}, 第i个信封的宽和高大于第i-1个信封。”锁链“的长度就是锁链中信封的数量。

Peter想用他所有的信封做一个最大的锁链,锁链要能够放下贺卡。当贺卡的长和宽都小于”锁链“中最小的信封的高和宽时,贺卡视为可以放下。禁止旋转卡片和信封。

Peter有很多信封,但是时间不多,这个艰巨的任务委托给你完成。

输入:
第一行包含整数n,w,h (1  ≤ n ≤ 5000, 1 ≤ w,  h  ≤ 106),分别表示信封的数量,卡片的宽和高。接下来n行,每行包含两个整数wi和hi,表示第i个信封的宽和高。(1 ≤ wi,  hi ≤ 106)。
输出:
第一行输出”锁链”的最大长度。第二行输出组成“锁链”的信封的序号,序号间用一个空格隔开,从序号最小的信封开始。注意,贺卡要能够放在最小的信封里。如果“锁链”的最大大小的方案不止一种,输出任意一种。
如果任何信封都放不下贺卡,输出0。
样例输入:
2 1 1
2 2
2 2
样例输出:
1

样例输入:
3 3 3
5 4
12 11
9 8
样例输出:
3
1 3 2 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值