This page is still under construction.

Parts of this page are still being built. What you see may change.

Mendelian Genetics

Time limit1sMemory limit128 MB

Summary
For each data set, find the n largest values among the ceil((x+y)/2) hybrid sizes formed by all pairs of n given sizes, sorted descending.
Level

Medium7 of 10

Topics
Sorting, Greedy, Binary search
Solved
No attempts yet

Problem

The Austrian monk Gregor Mendel (1822–1884) is regarded as the founding father of genetics for his pioneering theory of genotypic inheritance. In this problem you help Mendel speed up his pea-hybridization experiments.

Consider only one feature of the peas: their size. Starting from nn initial types, each with a size, hybridizing them pairwise yields n2n^2 hybrid types after one generation. Mendel wants larger peas, but he can afford to grow only nn of the n2n^2 candidates, so he must pick the nn most promising ones.

Without knowing the hidden genotypes, he estimates the size of the hybrid of two parents of sizes xx and yy with the formula

⌈x+y2⌉\left\lceil \frac{x + y}{2} \right\rceil

For example, if the two parents have sizes 55 and 22, the hybrid is estimated to have size ⌈7/2⌉=4\lceil 7/2 \rceil = 4.

Find the largest nn values in this n×nn \times n matrix of pairwise combinations. A type may also be combined with itself, i.e. the diagonal entries are included.

Input

The first line contains the number KK of data sets. Then follow KK data sets, each of the following form:

  • The first line contains an integer nn (1≤n≤100001 \le n \le 10000), the number of initial types.
  • The second line contains nn positive integers, the sizes of the initial types.

Output

For each data set, output Data Set x: on a line by itself, where xx is its number (starting from 11). On the next line output the largest nn numbers from the n×nn \times n matrix of combinations, sorted in descending order and separated by single spaces. Separate consecutive data sets with a single blank line.

Examples1

  1. Example 1

    Input
    2
    3
    3 1 2
    4
    3 8 5 1
    
    Expected output
    Data Set 1:
    3 3 3
    
    Data Set 2:
    8 7 7 6