Codeforces Round 887 (Div. 1) |
---|
Finished |
Ntarsis has come up with an array $$$a$$$ of $$$n$$$ non-negative integers.
Call an array $$$b$$$ of $$$n$$$ integers imbalanced if it satisfies the following:
Given the array $$$a$$$, Ntarsis wants you to construct some imbalanced array. Help him solve this task, or determine it is impossible.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^5$$$). The description of the test cases follows.
The first line of each test case has a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$).
The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \leq a_i \leq n$$$).
It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$10^5$$$.
For each test case, output "NO" if there exists no imbalanced array.
Otherwise, output "YES". Then, on the next line, output $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ where $$$b_i \neq 0$$$ for all $$$1 \leq i \leq n$$$ — an imbalanced array.
51141 4 3 430 1 044 3 2 131 3 1
YES 1 NO YES -3 1 -2 YES 4 2 -1 -3 YES -1 3 -1
For the first test case, $$$b = [1]$$$ is an imbalanced array. This is because for $$$i = 1$$$, there is exactly one $$$j$$$ ($$$j = 1$$$) where $$$b_1 + b_j > 0$$$.
For the second test case, it can be shown that there exists no imbalanced array.
For the third test case, $$$a = [0, 1, 0]$$$. The array $$$b = [-3, 1, -2]$$$ is an imbalanced array.
Name |
---|