#P4405. [ZJOI2009] 硬币游戏

[ZJOI2009] 硬币游戏

Description

Orez likes playing games, and he recently invented a coin game. He divides the edge of a table into 2n2n positions and labels them clockwise as 1,2,,2n1, 2, \ldots, 2n, then places nn coins on the positions with odd labels.

Each operation is as follows: place one coin between any two coins, and then remove those two original coins. The side of the newly placed coin is determined by the two coins on its sides. If both coins are heads up or both are tails up, the new coin is heads up; otherwise, it is tails up. After performing the operation TT times, what will the configuration of coins along the edge of the table be.

Input Format

The first line contains two integers nn and TT.

The next line contains nn integers, describing the initial arrangement of coins along the edge. The ii-th integer aia_i gives the state of the coin placed at position 2i12i-1, where ai=1a_i = 1 means heads up and ai=2a_i = 2 means tails up.

Output Format

Output a single line with 2n2n integers. The ii-th integer bib_i is the state at position ii along the edge of the table, where bi=1b_i = 1 means heads up, bi=2b_i = 2 means tails up, and bi=0b_i = 0 means there is no coin.

10 5
2 2 2 1 1 1 1 1 1 2
0 1 0 1 0 1 0 1 0 2 0 1 0 2 0 1 0 1 0 1

Hint

30% of the testdata: n1000n \le 1000, T1000T \le 1000.

100% of the testdata: n100000n \le 100000, T260T \le 2^{60}.

Sample explanation.

20202010101010101020
01010201010101010201
10102020101010102020
01020102010101020102
20202020201010202020
01010101020102010101

Translated by ChatGPT 5