题目描述
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given a strictly increasing sequence of integers $A_{1}, A_{2}, \ldots, A_{N}$. Your task is to compress this sequence.
The compressed form of this sequence is a sequence of ranges separated by commas (characters ','). A range is either an integer or a pair of integers separated by three dots (the string "..."). When each range a...b in the compressed form is decompressed into the subsequence $(a, a+1, \ldots, b)$, we should obtain the (comma-separated) sequence $A$ again.
For each maximal contiguous subsequence $(a, a+1, \ldots, b)$ of $A$ such that $b ≥ a+2$, the compressed form of $A$ must contain the range a...b; if $b ≤ a+1$, such a sequence should not be compressed into a range. A contiguous subsequence is maximal if it cannot be extended by at least one element of $A$ next to it. It can be proved that the compressed form of any sequence is unique (i.e. well-defined).
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains $N$ space-separated integers $A_{1}, A_{2}, \ldots, A_{N}$.
------ Output ------
For each test case, print a single line containing one string ― the compressed form of the given sequence.
------ Constraints ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$1 ≤ A_{i} ≤ 1,000$ for each valid $i$
$A_{1} < A_{2} < \ldots < A_{N}$
------ Subtasks ------
Subtask #1 (100 points): original constraints
----- Sample Input 1 ------
3
12
1 2 3 5 6 8 9 10 11 12 15 17
4
4 5 7 8
1
4
----- Sample Output 1 ------
1...3,5,6,8...12,15,17
4,5,7,8
4
----- explanation 1 ------
Example case 1:
- $(1, 2, 3)$ is a contiguous subsequence with length $3$, so it is replaced by the string "1...3"
- $(5, 6)$ is a contiguous subsequence, but only with length $2$, so it is not compressed into a range
- $(8, 9, 10, 11, 12)$ is a contiguous subsequence with length $5$, so it is replaced by "8...12"
- the elements $15$, $17$ are unaffected
输入格式
见题面
输出格式
见题面