#P12551. [UOI 2025] Simple Task

    ID: 14116 远端评测题 1500ms 256MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2025Special Judge分类讨论UOI(乌克兰)

[UOI 2025] Simple Task

题目描述

We call a non-empty sequence of positive integers strange if the sum of its elements is a prime number.

You are given an array aa of length nn, consisting of prime numbers. You are also given an integer kk.

Split the array aa into kk non-empty subsequences1^1 such that each element of the array aa belongs to exactly one of them, and the number of strange subsequences among the formed ones is minimized.

In this problem, each test contains several sets of input data. You need to solve the problem independently for each such set.

Note that there is no block "without additional constraints" in this problem.

输入格式

The first line contains one integer TT (1T105)(1\le T\le 10^5) --- the number of sets of input data. The description of the input data sets follows.

In the first line of each input data set, two integers nn, kk (1kn105)(1 \le k \le n \le 10^5) are given --- the length of the array aa and the number of subsequences into which it needs to be split.

In the second line of each input data set, nn prime numbers a1,a2,,ana_1, a_2, \ldots, a_n (2ai105,aiai+1)(2\le a_i\le 10^5, a_i\le a_{i+1}) are given --- the elements of the array aa.

It is guaranteed that the sum of nn across all input data sets of one test does not exceed 10510^5.

输出格式

For each set of input data, output the optimal partition in the following format:

  • In the first line, output one integer mm --- the number of strange subsequences among the formed ones;
  • In each of the next kk lines, output integers sis_i and b1,b2,,bsib_1, b_2, \ldots, b_{s_i} (1sin)(1\le s_i\le n) --- the number of elements in the corresponding subsequence of the partition and the elements themselves.

Subsequences and their elements may be output in any order.

If there are multiple correct answers, any of them is allowed.

4
3 1
5 5 13
4 2
2 3 5 7
5 3
3 3 5 5 13
6 5
2 2 2 3 3 3
1
3 13 5 5
0
2 2 7
2 3 5
1
1 13
2 3 3
2 5 5
4
1 2
1 2
1 2
1 3
2 3 3

提示

1^1 A sequence cc is called a subsequence of an array bb if it is possible to remove a certain number of elements from the array bb (possibly zero) so that the sequence cc is formed.

Scoring

  • (22 points): T20T \leq 20, k=1k=1;
  • (55 points): n4n \leq 4, ai104a_i \leq 10^4 for all 1in1\le i\le n;
  • (88 points): T20T \leq 20, n10n \leq 10, ai104a_i \leq 10^4 for all 1in1\le i\le n;
  • (44 points): nn --- even, ai>2a_i > 2 for all 1in1\le i\le n;
  • (1818 points): nn --- odd, ai>2a_i > 2 for all 1in1\le i\le n;
  • (1010 points): 2kn+12\cdot k \ge n + 1;
  • (2929 points): nn --- even;
  • (2424 points): nn --- odd.