QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#10254. Chair Game

統計

Consider a game with $n$ players and $n$ chairs. The chairs will be arranged in a circle, and each player will sit on a chair. There is also a bell which will ring some number of times during the game.

Each chair has an integer between $1$ and $n$: the number of steps the player who sits on that chair must move clockwise when the bell rings. A chair arrangement is valid if each chair will have exactly one player after the bell rings.

Your task is to find a valid chair arrangement or state that there is no such arrangement.

Input

The first line has an integer $t$: the number of tests.

After this, each test consists of two lines. The first line has an integer $n$. The second line has integers $s_1,s_2,\dots,s_n$: the numbers on the chairs.

Output

For each test, first print YES if there is a valid chair arrangement and NO otherwise. If the answer is YES, also print a possible arrangement clockwise. If there are several valid arrangements, you can print any of them.

Constraints

  • $1 \le t \le 1000$
  • $1 \le n \le 100$
  • $1 \le s_i \le n$ for $i=1,2,\dots,n$

Example

Input:

3
4
1 1 1 1
4
1 1 1 2
5
4 1 2 1 2

Output:

YES
1 1 1 1
NO
YES
2 4 1 1 2

Subtask 1 (8 points)

  • $1 \le n \le 8$

Subtask 2 (5 points)

  • $s_i \neq s_j$ if $i \neq j$ (i.e. each value is distinct)

Subtask 3 (4 points)

  • $1 \le s_i \le 2$ for $i=1,2,\dots,n$

Subtask 4 (7 points)

  • $1 \le s_i \le 3$ for $i=1,2,\dots,n$

Subtask 5 (12 points)

  • $1 \le s_i \le 4$ for $i=1,2,\dots,n$

Subtask 6 (15 points)

  • $1 \le s_i \le 5$ for $i=1,2,\dots,n$

Subtask 7 (20 points)

  • $1 \le n \le 16$

Subtask 8 (29 points)

  • No restrictions.
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.