A1394.[COCI-2008_2009-contest6]#3 CUSKIJA
普及/提高-
COCI
通过率:0%
时间限制:1.00s
内存限制:128MB
题目描述
Rearrange the given array of integers so that the sum of two adjacent elements is never divisible by three.
输入格式
The first line contains an integer N (1 ≤ N ≤ 10000), the number of elements in the array.
The second line contains the elements of the array separated by single spaces. The elements will be positive integers less than 100000
0.
输出格式
If any valid rearrangement exists, output it on a single line. Otherwise, output "impossible".
输入输出样例
输入#1
3 1 2 3
输出#1
2 3 1
输入#2
5 4 6 3 9 8
输出#2
3 4 6 8 9
输入#3
6 3 7 6 4 2 8
输出#3
3 7 4 6 2 8