CF1857C.Assembly via Minimums
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Sasha has an array a of n integers. He got bored and for all i , j ( i<j ), he wrote down the minimum value of ai and aj . He obtained a new array b of size 2n⋅(n−1) .
For example, if a= [ 2,3,5,1 ], he would write [ min(2,3),min(2,5),min(2,1),min(3,5),min(3,1),min(5,1) ] = [ 2,2,1,3,1,1 ].
Then, he randomly shuffled all the elements of the array b .
Unfortunately, he forgot the array a , and your task is to restore any possible array a from which the array b could have been obtained.
The elements of array a should be in the range [−109,109] .
输入格式
The first line contains a single integer t ( 1≤t≤200 ) — the number of test cases.
The first line of each test case contains a single integer n ( 2≤n≤103 ) — the length of array a .
The second line of each test case contains 2n⋅(n−1) integers b1,b2,…,b2n⋅(n−1) ( −109≤bi≤109 ) — the elements of array b .
It is guaranteed that the sum of n over all tests does not exceed 103 and for each array b in the test, there exists an original array.
输出格式
For each test case, output any possible array a of length n .
输入输出样例
输入#1
5 3 1 3 1 2 10 4 7 5 3 5 3 3 5 2 2 2 2 2 2 2 2 2 2 5 3 0 0 -2 0 -2 0 0 -2 -2
输出#1
1 3 3 10 10 7 5 3 12 2 2 2 2 2 0 -2 0 3 5
说明/提示
In the first sample, Sasha chose the array [1,3,3] , then the array b will look like [min(a1,a2)=1,min(a1,a3)=1,min(a2,a3)=3] , after shuffling its elements, the array can look like [1,3,1] .
In the second sample, there is only one pair, so the array [10,10] is suitable. Another suitable array could be [15,10] .