410782: GYM104103 C Password Lock

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Password Locktime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Andrey got a cool new lock for his birthday. You can set several passwords on it at the same time; when you enter any of them, the lock opens.

The lock consists of a sequence of cells, each has an integer written on it. You can swap places of any two cells any number of times; when they are arranged in any correct order, the lock opens. The order is considered correct when the sum of two integers on any pair of adjacent cells is not divisible by $$$k$$$.

You found out about the structure of this lock and, of course, decided to try to open it. Given the numbers on the cells and the value of $$$k$$$, find the permutation of cells that opens the lock.

Input

The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le k \le 10^9$$$) — the number of cells on the lock and the number $$$k$$$.

The second line of the input contains $$$n$$$ integers $$$a_i$$$ ($$$1 \le a_i \le 10^9$$$) — the initial configuration of cells on the lock.

Output

If there is no suitable permutation of cells, print "NO" (without quotes, case insensitive) on the first line.

If a suitable permutation of cells exists, print "YES" (no quotes, case insensitive) on the first line. In the second line, print $$$n$$$ integers — the permutation itself.

Scoring
SubtaskPointsConstraints
$$$1$$$$$$8$$$$$$n \le 8$$$
$$$2$$$$$$8$$$$$$k = 2$$$
$$$3$$$$$$8$$$$$$k = 3$$$
$$$4$$$$$$8$$$$$$n = k$$$; numbers $$$a_i$$$ are distinct and are between $$$1$$$ and $$$n$$$
$$$5$$$$$$25$$$$$$k$$$ is odd
$$$6$$$$$$43$$$No additional restrictions
ExamplesInput
3 4
1 3 2
Output
YES
1 2 3 
Input
5 4
1 2 2 2 4
Output
YES
2 4 2 1 2 

加入题单

上一题 下一题 算法标签: