题库练习 Assembly via Minimums
← 上一题 下一题 →

A16126 | Assembly via Minimums

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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 $a_i$ and $a_j$ . He obtained a new array $b$ of size $\frac{n\cdot (n-1)}{2}$ .

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 $[-10^9,10^9]$ .

输入格式

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

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

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

It is guaranteed that the sum of $n$ over all tests does not exceed $10^3$ 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
C++ 编辑器
输入
输出