Logo
(追記) (追記ここまで)

35025번 - High Score 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB666100.000%

문제

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 0ドル$. At any moment in the game, the multiset contains at most $k$ integers (not necessarily distinct). In one turn, the player can choose one of the following moves:

  • Insert. Choose an integer 2ドル$ or 4ドル$ 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 $k$.
  • Merge. Choose an integer $x$ such that the multiset contains at least two copies of $x$. Remove two copies of $x$ from the multiset, and insert one copy of 2ドルx$ into the multiset. This move adds the value 2ドルx$ 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: $h_1, h_2, \ldots, h_n$ in some order. Now she is curious how she managed to achieve those scores.

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

입력

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

Each of the next $n$ lines contains a single integer $h_i,ドル denoting a score on the leaderboard (1ドル \le h_i \le 10^9$).

출력

For each score $h_i,ドル print the final size of the multiset $s,ドル followed by $s$ integers describing the contents of the multiset in any order (0ドル \le s \le k$). It must be possible to achieve the score $h_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 $h_i$ at the end of the game, print a single integer $-1$ instead.

제한

예제 입력 1

1 2
12

예제 출력 1

1 8

예제 입력 2

4 5
4
12
10
20

예제 출력 2

2 4 2
5 8 4 2 2 4
-1
3 2 4 8

예제 입력 3

1 16
19956

예제 출력 3

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\} $

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2025-2026 Northwestern Russia Regional Contest H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /