luogu#P4934. 礼物

    ID: 3884 远端评测题 2000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>Special JudgeO2优化枚举排序拓扑排序洛谷月赛

礼物

Background

Because you did an excellent job on the previous two problems, the kind __stdcall decided to give you a small gift, providing strong support for you who are striving to AK this problem set.

Problem Description

__stdcall decided to give you nn gifts. Each gift has a magic value aia_i.

All magic values are unique, i.e., pairwise distinct. These gifts have magical power: if for two gifts i,ji, j, their magic values satisfy aibitandajmin(ai,aj)a_i \operatorname{bitand} a_j \ge \min(a_i, a_j), then their magic will cancel each other out, so they cannot be put into the same box.

Here bitand\operatorname{bitand} denotes the bitwise AND operation. If you are not familiar with it, please refer to: https://baike.baidu.com/item/按位与/9601818.

As the gift delivery worker, ljt12138 does not have many boxes, but luckily each box is large enough. Now he asks you to help him distribute the gifts properly, using as few boxes as possible. In other words, make sure every gift is placed into exactly one box, and the gifts in the same box will not cancel each other out. If there are multiple valid solutions, you only need to output any one.

ljt12138 is very kind: if you can only compute the required number of boxes, you can still get 60%60\% of the score for that test point. For details, see the hints and explanations below.

Input Format

  • The first line contains two numbers nn and kk, where nn is the total number of gifts, and kk is a parameter to help you compute.
  • The second line contains nn pairwise distinct numbers aia_i, satisfying 0ai<2k0 \le a_i < 2^k, representing the magic values of the gifts.

Output Format

  • Output one number on the first line. If you do not want to output an assignment, output 00; if you want to output an assignment, output 11. If you output invalid information on this line, you will be judged as WA.
  • Output one number mm on the second line, indicating that you packed the gifts into mm boxes.
  • If you output 11 on the first line, then output the next mm lines, each describing one box: first a number sis_i, the number of gifts in the current box; then sis_i numbers describing the current subset.
5 3
0 4 7 1 6 

1
4
1 0
2 1 4
1 6
1 7 

Hint

Additional Samples

You can download additional samples at https://pan.baidu.com/s/1A8_ZA4yXXi5y6771x9JKUw.

About Outputting an Assignment

  • If you output 00 on the first line and correctly answer the minimum number of boxes needed, you will get 60%60\% of the score for that test point.
  • If you output 11 on the first line, correctly answer the minimum number of boxes needed, but do not provide a correct assignment, you will also get 60%60\% of the score for that test point.
  • If you do not correctly answer the minimum number of boxes needed, you will not get the score for that test point.
  • Please note that if you do not output in the format above, you will not receive any score.

The relationship between nn and kk is given by the table below:

Data ID nn kk
11 55 33
22 66
33 77 1010
44 88
55 1616 77
66 1717 88
77 99
88 2020
99 2×1032\times 10^3 1717
1010 2.5×1032.5\times 10^3 1818
1111 3×1033\times 10^3 1919
1212 2020
1313 2.5×1042.5\times 10^4 1515
1414
1515 5×1045\times 10^4 1616
1616
1717 2.5×1052.5\times 10^5 1818
1818 5×1055\times 10^5 1919
1919 10610^6 2020
2020

Translated by ChatGPT 5