cswork / OA打开练习工作台

AtlassianOA #1

Better Compression

估计简单可在线判题

考点(AI 标注)字符串哈希计数

The input consists of lowercase letters, each followed by a positive decimal frequency, and the same letter may appear multiple times. Accumulate the frequencies, then in ascending letter order output each letter that occurs, listed only once together with its total frequency.

输入格式

A single line containing the compressed string S. Original bounds: 1≤|S|≤100000; each segment has a letter a..z and a frequency 1..1000; the input must be a complete valid letter-frequency sequence, so a valid string has length at least 2. This site uses frequency encoding without leading zeros.

输出格式

Output the unique canonical compressed string.

样例 1

输入:

a3c9b2c1

输出:

a3b2c10

样例 2

输入:

z1000a1z10

输出:

a1z1010

样例 3

输入:

a1

输出:

a1

样例说明

The outputs of the three public examples are, in order: a3b2c10; a1z1010; a1. Verified by independent enumeration or direct simulation.