8565: Constructive Problems Never Die

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:Special Judge 上传者:
提交:3 通过:0

题目描述

链接:https://ac.nowcoder.com/acm/contest/33192/C
来源:牛客网
Grammy has a sequence A of length n.

Please find a permutation P such that Pi≠Ai for all i.

输入格式


There are multiple test cases.
The first line contains a single integer TTT (1≤T≤1000001 \leq T \leq 100\,0001T100000), denoting the number of test cases.
For each test case:
The first line contains a single integer nnn (1≤n≤1000001 \leq n \leq 100\, 0001n100000).
The second line contains nnn integers A1,A2,…,AnA_1,A_2,\dots,A_nA1,A2,,An (1≤Ai≤n1 \leq A_i \leq n1Ain).
It is guaranteed that the sum of nnn does not exceed 500000500\,000500000.

输出格式


For each test case:
If the permutation does not exist, output “NO” in one line.
Otherwise output “YES” in the first line, then output nnn integers in the second line, denoting the permutation P1,P2,…,PnP_1,P_2,\dots,P_nP1,P2,,Pn.

输入样例 复制

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

分类标签