아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Oscar's Round Must Have a Constructive Problem

면접 대비

시간 제한1초메모리 제한1024 MB

요약
수열 A가 주어질 때 모든 i에서 P[i] != A[i]인 순열 P를 만들거나, 불가능하면 불가능하다고 답한다.
난이도

보통10점 중 5점

유형
그리디, 정렬, 조합론
정답자
아직 제출이 없습니다

문제

Grammy has a sequence AA of length nn.

Please find a permutation PP such that P_i≠A_iP\_i \neq A\_i for all ii.

입력

There are multiple test cases.

The first line contains a single integer TT (1≤T≤100,0001 \leq T \leq 100\\,000), denoting the number of test cases.

For each test case:

The first line contains a single integer nn (1≤n≤100,0001 \leq n \leq 100\\,000).

The second line contains nn integers A_1,A_2,…,A_nA\_1,A\_2,\ldots,A\_n (1≤A_i≤n1 \leq A\_i \leq n).

It is guaranteed that the sum of nn does not exceed 500,000500\\,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 nn integers one the second line, denoting the permutation P_1,P_2,…,P_nP\_1,P\_2,\ldots,P\_n.

예제1

  1. 예제 1

    입력
    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