CF1857C.Assembly via Minimums

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Sasha has an array aa of nn integers. He got bored and for all ii , jj ( i<ji < j ), he wrote down the minimum value of aia_i and aja_j . He obtained a new array bb of size n(n1)2\frac{n\cdot (n-1)}{2} .

For example, if a=a= [ 2,3,5,12,3,5,1 ], he would write [ min(2,3),min(2,5),min(2,1),min(3,5),min(3,1),min(5,1)\min(2, 3), \min(2, 5), \min(2, 1), \min(3, 5), \min(3, 1), min(5, 1) ] == [ 2,2,1,3,1,12, 2, 1, 3, 1, 1 ].

Then, he randomly shuffled all the elements of the array bb .

Unfortunately, he forgot the array aa , and your task is to restore any possible array aa from which the array bb could have been obtained.

The elements of array aa should be in the range [109,109][-10^9,10^9] .

输入格式

The first line contains a single integer tt ( 1t2001\le t\le 200 ) — the number of test cases.

The first line of each test case contains a single integer nn ( 2n1032\le n\le 10^3 ) — the length of array aa .

The second line of each test case contains n(n1)2\frac{n\cdot (n-1)}{2} integers b1,b2,,bn(n1)2b_1,b_2,\dots,b_{\frac{n\cdot (n-1)}{2}} ( 109bi109−10^9\le b_i\le 10^9 ) — the elements of array bb .

It is guaranteed that the sum of nn over all tests does not exceed 10310^3 and for each array bb in the test, there exists an original array.

输出格式

For each test case, output any possible array aa of length nn .

输入输出样例

  • 输入#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][1,3,3] , then the array bb will look like [min(a1,a2)=1,min(a1,a3)=1,min(a2,a3)=3][\min(a_1,a_2)=1, \min(a_1,a_3)=1, \min(a_2,a_3)=3] , after shuffling its elements, the array can look like [1,3,1][1,3,1] .

In the second sample, there is only one pair, so the array [10,10][10,10] is suitable. Another suitable array could be [15,10][15,10] .

首页