CF1656G.Cycle Palindrome
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
We say that a sequence of n integers a1,a2,…,an is a palindrome if for all 1≤i≤n , ai=an−i+1 . You are given a sequence of n integers a1,a2,…,an and you have to find, if it exists, a cycle permutation σ so that the sequence aσ(1),aσ(2),…,aσ(n) is a palindrome.
A permutation of 1,2,…,n is a bijective function from {1,2,…,n} to {1,2,…,n} . We say that a permutation σ is a cycle permutation if 1,σ(1),σ2(1),…,σn−1(1) are pairwise different numbers. Here σm(1) denotes m timesσ(σ(…σ(1)…)) .
输入格式
The input consists of multiple test cases. The first line contains a single integer t ( 1≤t≤3⋅104 ) — the number of test cases. Description of the test cases follows.
The first line of each test case contains an integer n ( 2≤n≤2⋅105 ) — the size of the sequence.
The second line of each test case contains n integers a1,…,an ( 1≤ai≤n ).
The sum of n for all test cases is at most 2⋅105 .
输出格式
For each test case, output one line with YES if a cycle permutation exists, otherwise output one line with NO.
If the answer is YES, output one additional line with n integers σ(1),σ(2),…,σ(n) , the permutation. If there is more than one permutation, you may print any.
输入输出样例
输入#1
3 4 1 2 2 1 3 1 2 1 7 1 3 3 3 1 2 2
输出#1
YES 3 1 4 2 NO YES 5 3 7 2 6 4 1