#K4776. Make the Sequence Strictly Increasing
Make the Sequence Strictly Increasing
Make the Sequence Strictly Increasing
You are given multiple queries. In each query, you are provided with a sequence of integers. Your task is to rearrange the sequence into non-decreasing order and then check whether the sorted sequence is strictly increasing (i.e. for every \(i\), \(a_i < a_{i+1}\)).
If the sorted sequence is strictly increasing, print the sequence (with elements separated by a single space). Otherwise, print Impossible
.
Note: A sequence is strictly increasing if and only if every two consecutive elements satisfy \(a_i < a_{i+1}\). Duplicates are not allowed in the finalized sequence.
Example:
Input: 3 5 1 2 3 4 5 4 3 1 2 4 3 7 5 7</p>Output: 1 2 3 4 5 1 2 3 4 Impossible
inputFormat
The input is read from stdin and has the following format:
- The first line contains a single integer \(T\) indicating the number of queries.
- For each query, the first line contains an integer \(n\), the number of elements in the sequence, followed by a line with \(n\) space-separated integers.
For example:
3 5 1 2 3 4 5 4 3 1 2 4 3 7 5 7
outputFormat
For each query, output the result on a new line to stdout. If the sorted sequence is strictly increasing, output the numbers (separated by a space). Otherwise, output Impossible
.
3
5
1 2 3 4 5
4
3 1 2 4
3
7 5 7
1 2 3 4 5
1 2 3 4
Impossible
</p>