Codeforces Beta Round 34(Div. 2)
C
页码
Page Numbers
Codeforces
1300
原题
← BD →

页码AI (CI翻译)

«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without spaces).

翻译中…

Your task is to write a part of the program, responsible for «standardization» of this sequence. Your program gets the sequence, keyed by the user, as input. The program should output this sequence in format $*l*_{1}$-$*r*_{1}$,$*l*_{2}$-$*r*_{2}$,...,$*l*_{*k*}$-$*r*_{*k*}$, where $*r*_{*i*} + 1 < *l*_{*i* + 1}$ for all $*i*$ from $1$ to $*k* - 1$, and $*l*_{*i*} ≤ *r*_{*i*}$. The new sequence should contain all the page numbers, keyed by the user, and nothing else. If some page number appears in the input sequence several times, its appearances, starting from the second one, should be ignored. If for some element $*i*$ from the new sequence $*l*_{*i*} = *r*_{*i*}$, this element should be output as $*l*_{*i*}$, and not as «$*l*_{*i*} - *l*_{*i*}$».

翻译中…

For example, sequence 1,2,3,1,1,2,6,6,2 should be output as 1-3,6.

翻译中…

Input

输入格式

AI (CI翻译)

The only line contains the sequence, keyed by the user. The sequence contains at least one and at most 100 positive integer numbers. It's guaranteed, that this sequence consists of positive integer numbers, not exceeding 1000, separated with a comma, doesn't contain any other characters, apart from digits and commas, can't end with a comma, and the numbers don't contain leading zeroes. Also it doesn't start with a comma or contain more than one comma in a row.

唯一一行包含用户输入的页码序列。该序列至少包含一个、至多包含 100 个正整数。保证该序列由不超过 1000 的正整数组成,整数之间以逗号分隔,不包含除数字和逗号以外的其他字符,不以逗号结尾,且数字不含前导零。同时,序列不以逗号开头,也不包含连续的多个逗号。AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output the sequence in the required format.

按照要求的格式输出该序列。AI (CI翻译)

样例

Input #1
1,2,3,1,1,2,6,6,2
Output #1
1-3,6
InputCopy OutputCopy
Input #2
3,2,1
Output #2
1-3
InputCopy OutputCopy
Input #3
30,20,10
Output #3
10,20,30
InputCopy OutputCopy
题目信息
题号
34C
时间限制
2 s
内存限制
256 MB
标签
表达式解析
模拟
排序
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。