codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

246C.md (2515B)


      1 Source: https://codeforces.com/problemset/problem/246/C
      2 
      3 C. Beauty Pageant
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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.
     22 
     23 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.
     24 
     25 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.
     26 
     27 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.
     28 
     29 Input
     30 
     31 The first line contains two integers *n*, *k* (1 ≤ *n* ≤ 50; 1 ≤ *k* ≤  ![](https://espresso.codeforces.com/5e54199c623e6698508e30637903d25ae30f0d42.png)) — 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.
     32 
     33 It is guaranteed that Payne's battalion doesn't have two soldiers with the same beauty.
     34 
     35 Output
     36 
     37 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.
     38 
     39 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.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 3 3  
     47 1 2 3
     48 ```
     49 
     50 Output
     51 
     52 ```
     53 1 1  
     54 1 2  
     55 2 3 2
     56 ```
     57 
     58 Input
     59 
     60 ```
     61 2 1  
     62 7 12
     63 ```
     64 
     65 Output
     66 
     67 ```
     68 1 12
     69 ```