QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 32 MB 총점: 100

#17093. Cuskija

통계

重新排列给定的整数数组,使得任意两个相邻元素的和都不能被 $3$ 整除。

输入格式

第一行包含一个整数 $N$ ($1 \le N \le 10000$),表示数组中元素的个数。

第二行包含数组中的元素,由单个空格分隔。这些元素都是小于 $1000000$ 的正整数。

输出格式

如果存在任何合法的重新排列,在单行中输出它。否则,输出 "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

输入样例 4

3
3 12 9

输出样例 4

impossible

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.