#P14607. [NWRRC 2025] High Score

[NWRRC 2025] High Score

题目描述

Hermione loves to play the following computer game, in which the player controls an unordered multiset of integers. Initially, the multiset is empty and the player's score is 00. At any moment in the game, the multiset contains at most kk integers (not necessarily distinct). In one turn, the player can choose one of the following moves:

  • Insert\textbf{Insert}. Choose an integer 22 or 44 and insert it into the multiset. This move does not change the score, and it is only allowed if the size of the multiset before the move is strictly less than kk.
  • Merge\textbf{Merge}. Choose an integer xx such that the multiset contains at least two copies of xx. Remove two copies of xx from the multiset, and insert one copy of 2x2x into the multiset. This move adds the value 2x2x to the player's score.

The player can stop the game after any turn, at which point the player's score becomes final.

Hermione has been on vacation for the whole summer, and she hasn't played the game in a while. Today, she opened the game on her laptop and saw the leaderboard with the highest scores she's ever had: h1,h2,,hnh_1, h_2, \ldots, h_n in some order. Now she is curious how she managed to achieve those scores.

For each hih_i, find any multiset of integers that Hermione could have at the end of the game if her final score was hih_i, or determine that it is impossible to achieve such a score.

输入格式

The first line contains two integers nn and kk, denoting the number of scores on the leaderboard and the maximum size of the multiset (1n1041 \le n \le 10^4; 2k162 \le k \le 16).

Each of the next nn lines contains a single integer hih_i, denoting a score on the leaderboard (1hi1091 \le h_i \le 10^9).

输出格式

For each score hih_i, print the final size of the multiset ss, followed by ss integers describing the contents of the multiset in any order (0sk0 \le s \le k). It must be possible to achieve the score hih_i with this multiset at the end of the game. If there are multiple answers, print any of them.

If it is impossible to have the score hih_i at the end of the game, print a single integer 1-1 instead.

1 2
12
1 8
4 5
4
12
10
20
2 4 2
5 8 4 2 2 4
-1
3 2 4 8
1 16
19956
1 2048

提示

A possible sequence of moves for the first test is shown below:

$$\{\} \xrightarrow{\texttt{insert 2}} \{2\} \xrightarrow{\texttt{insert 2}} \{2, 2\} \xrightarrow[\texttt{score += 4}]{\texttt{merge, x = 2}} \{4\} \xrightarrow{\texttt{insert 4}} \{4, 4\} \xrightarrow[\texttt{score += 8}]{\texttt{merge, x = 4}} \{8\}$$