시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 66 | 22 | 21 | 35.593% |
Find a sequence of steps of the following kind (if it exists) that would make all elements of any array of real numbers a1, a2, . . . , an equal:
pick k distinct indices b1, b2, . . . , bk (1 ≤ bi ≤ n) and change the values of ab1, ab2, . . . , abk to their arithmetic mean (that is, 1/k (ab1 + ab2 + . . . + abk)) simultaneously.
The only line contains two integers n and k (2 ≤ k ≤ n ≤ 1000; n is divisible by k).
If a required sequence of steps doesn’t exist, display a single integer −1.
Otherwise, display the number of steps in your sequence t (1 ≤ kt ≤ 106), followed by t step descriptions. Each step description must consist of k distinct integers b1, b2, . . . , bk (1 ≤ bi ≤ n).
It can be shown that if a valid sequence of steps exists, a sequence satisfying kt ≤ 106 exists as well.
4 2
4 1 2 3 4 1 3 2 4
6 3
-1