시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 1024 MB | 112 | 37 | 24 | 35.294% |
Grammy has a sequence $A$ of length $n$.
Please find a permutation $P$ such that $P_i \neq A_i$ for all $i$.
There are multiple test cases.
The first line contains a single integer $T$ ($1 \leq T \leq 100\,000$), denoting the number of test cases.
For each test case:
The first line contains a single integer $n$ ($1 \leq n \leq 100\,000$).
The second line contains $n$ integers $A_1,A_2,\ldots,A_n$ ($1 \leq A_i \leq n$).
It is guaranteed that the sum of $n$ does not exceed $500\,000$.
For each test case:
If the permutation does not exist, output "NO
" on a single line.
Otherwise, output "YES
" one the first line, then output $n$ integers one the second line, denoting the permutation $P_1,P_2,\ldots,P_n$.
3 3 3 3 3 3 3 2 1 6 1 1 4 5 1 4
NO YES 1 3 2 YES 4 5 1 2 3 6