Logo
(追記) (追記ここまで)

25647번 - Oscar's Round Must Have a Constructive Problem 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB159594535.156%

문제

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$.

제한

예제 입력 1

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

예제 출력 1

NO
YES
1 3 2
YES
4 5 1 2 3 6

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2022 > Day 2: ZJU Contest 1 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /