Compress the List
All submissions for this problem are available.### Read problem statements in [Bengali](http://www.codechef.com/download/translated/LTIME78/bengali/CMPRSS.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/LTIME78/mandarin/CMPRSS.pdf), [Russian](http://www.codechef.com/download/translated/LTIME78/russian/CMPRSS.pdf), and [Vietnamese](http://www.codechef.com/download/translated/LTIME78/vietnamese/CMPRSS.pdf) 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 \ge a+2$, the compressed form of $A$ must contain the range `a...b`; if $b \le 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 \le T \le 100$ - $1 \le N \le 100$ - $1 \le A_i \le 1,000$ for each valid $i$ - $A_1 \lt A_2 \lt \ldots \lt A_N$ ### Subtasks **Subtask #1 (100 points):** original constraints ### Example Input ``` 3 12 1 2 3 5 6 8 9 10 11 12 15 17 4 4 5 7 8 1 4 ``` ### Example Output ``` 1...3,5,6,8...12,15,17 4,5,7,8 4 ``` ### Explanation **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
|Tags||cakewalk, deadwing97, jafarbadour, ltime78|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.