#P6470. [COCI 2008/2009 #6] CUSKIJA

[COCI 2008/2009 #6] CUSKIJA

Description

Given a sequence aa of length nn, reorder it so that in the new sequence, the sum of any two adjacent numbers is not divisible by 33.

Input Format

The first line contains an integer nn, the length of the sequence.

The second line contains nn integers. The ii-th integer is the ii-th element of the sequence, aia_i.

Output Format

This problem uses Special Judge.

  • If a solution exists, output a string Yes on the first line, and on the second line output nn integers, where the ii-th integer is the ii-th element of the new sequence.
  • If no solution exists, output only a string No on one line.
3
1 2 3

Yes
2 3 1
5
4 6 3 9 8

Yes
3 4 6 8 9
6
3 7 6 4 2 8

Yes
3 7 4 6 2 8

3
3 12 9

No

Hint

Constraints

For all testdata, it is guaranteed that 1n1041 \leq n \leq 10^4 and 1ai1061 \leq a_i \leq 10^6.

[Notes]

This problem is translated from COCI2008-2009 CONTEST #6 T4 CUSKIJA. The translation and SPJ are provided by @一扶苏一. For easier SPJ checking, the output format is slightly modified compared to the original problem.

Translated by ChatGPT 5