CF246C.Beauty Pageant

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

General Payne has a battalion of n soldiers. The soldiers' beauty contest is coming up, it will last for k days. Payne decided that his battalion will participate in the pageant. Now he has choose the participants.

All soldiers in the battalion have different beauty that is represented by a positive integer. The value a__i represents the beauty of the i-th soldier.

On each of k days Generals has to send a detachment of soldiers to the pageant. The beauty of the detachment is the sum of the beauties of the soldiers, who are part of this detachment. Payne wants to surprise the jury of the beauty pageant, so each of k days the beauty of the sent detachment should be unique. In other words, all k beauties of the sent detachments must be distinct numbers.

Help Payne choose k detachments of different beauties for the pageant. Please note that Payne cannot just forget to send soldiers on one day, that is, the detachment of soldiers he sends to the pageant should never be empty.

佩恩将军拥有一支由 nn 名士兵组成的部队。士兵们的选美比赛即将开始,将持续 kk 天。佩恩决定让他的部队参加此次选美大赛,现在他需要从中选出参赛人员。

部队中每名士兵的“美貌值”均不相同,且以正整数表示。其中,aia_i 表示第 ii 名士兵的美貌值。

在接下来的 kk 天里,将军每天需派出一支小分队参加选美比赛。小分队的“美貌值”定义为该小分队中所有士兵美貌值之和。佩恩希望给选美大赛评委留下深刻印象,因此要求这 kk 天派出的小分队的美貌值互不相同。换言之,这 kk 个美貌值必须是 kk 个互异的数。

请帮助佩恩为选美大赛选出 kk 支美貌值互不相同的队伍。请注意:佩恩不能在某一天不派任何士兵参赛,即每天派出的小分队不能为空。

输入格式

The first line contains two integers n, k (1 ≤ n ≤ 50; 1 ≤ k ≤  ) — the number of soldiers and the number of days in the pageant, correspondingly. The second line contains space-separated integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 107) — the beauties of the battalion soldiers.

It is guaranteed that Payne's battalion doesn't have two soldiers with the same beauty.

第一行包含两个整数 nn、kk(1≤n≤501 \leq n \leq 50;1≤k≤1 \leq k \leq ),分别表示士兵人数和阅兵式持续的天数。
第二行包含 nn 个用空格分隔的整数 a1, a2, …, ana_1,\ a_2,\ \dots,\ a_n(1≤ai≤1071 \leq a_i \leq 10^7),表示该营士兵的美貌值。

保证佩恩(Payne)营中没有两名士兵具有相同的美貌值。

输出格式

Print k lines: in the i-th line print the description of the detachment that will participate in the pageant on the i-th day. The description consists of integer c__i (1 ≤ c__i ≤ n) — the number of soldiers in the detachment on the i-th day of the pageant and c__i distinct integers _p_1, i, _p_2, i, ..., p__c__i, i — the beauties of the soldiers in the detachment on the i-th day of the pageant. The beauties of the soldiers are allowed to print in any order.

Separate numbers on the lines by spaces. It is guaranteed that there is the solution that meets the problem conditions. If there are multiple solutions, print any of them.

输出 k 行:第 i 行输出参加第 i 天选美比赛的分队描述。该描述包含一个整数 c__i(1 ≤ c__i ≤ n),表示第 i 天选美比赛中该分队的士兵人数,以及 c__i 个互不相同的整数 _p_1, i, _p_2, i, ..., p__c__i, i —— 表示该分队中各位士兵在第 i 天选美比赛中的美貌值。士兵美貌值的输出顺序可以任意。

每行内的数字用空格分隔。题目保证存在满足条件的解。若存在多个解,输出其中任意一个即可。

输入输出样例

  • 输入#1

    3 3
    1 2 3

    输出#1

    1 1
    1 2
    2 3 2
  • 输入#2

    2 1
    7 12

    输出#2

    1 12

输入解题思路,AI测评打分。不知道怎么写?

首页