CF1768C.Elemental Decompress
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a of n integers.
Find two permutations † p and q of length n such that max(pi,qi)=ai for all 1≤i≤n or report that such p and q do not exist.
† A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation ( 2 appears twice in the array), and [1,3,4] is also not a permutation ( n=3 but there is 4 in the array).
输入格式
The first line contains a single integer t ( 1≤t≤104 ) — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer n ( 1≤n≤2⋅105 ).
The second line of each test case contains n integers a1,a2,…,an ( 1≤ai≤n ) — the array a .
It is guaranteed that the total sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case, if there do not exist p and q that satisfy the conditions, output "NO" (without quotes).
Otherwise, output "YES" (without quotes) and then output 2 lines. The first line should contain n integers p1,p2,…,pn and the second line should contain n integers q1,q2,…,qn .
If there are multiple solutions, you may output any of them.
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).
输入输出样例
输入#1
3 1 1 5 5 3 4 2 5 2 1 1
输出#1
YES 1 1 YES 1 3 4 2 5 5 2 3 1 4 NO
说明/提示
In the first test case, p=q=[1] . It is correct since a1=max(p1,q1)=1 .
In the second test case, p=[1,3,4,2,5] and q=[5,2,3,1,4] . It is correct since:
- a1=max(p1,q1)=max(1,5)=5 ,
- a2=max(p2,q2)=max(3,2)=3 ,
- a3=max(p3,q3)=max(4,3)=4 ,
- a4=max(p4,q4)=max(2,1)=2 ,
- a5=max(p5,q5)=max(5,4)=5 .
In the third test case, one can show that no such p and q exist.