当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3058:Decompression

题目描述
Consider the following scheme: for permuting a string of letters: first we create all different rotations of the string, then we sort them in lexicographical order, and finally we take the last letter of each rotation and concatenate them to form a new string.

For the string "LEIDEN.", for example, the seven rotation in lexicographical order are(where the period '.' comes before any letter):
.LEIDEN

DEN.LEI
EIDEN.L
EN.LEID
IDEN.LE
LEIDEN.
N.LEIDE
so this results in the string "NILDE.E"

At first glance this permutation doesn't seem useful at all but it has an interesting property. If there are a lot of equal substrings in the original string (which might happen in case of a real language), the a lot of equal consecutive letters occur after the permutaion. Therefor the resulting string is very suitable for block compression. where blocks of equals letters are replaced by that letter followd by a number which specifies how often that letter occurs. If the letter only occurs once, no number is added. For example the string "AAABCC" would be replaced by "A3BC2".

Your task is now to decompress this final string to the original string. Note however, that permuting the string it not entirely reversible: you can only obtain the original string up to a rotaion (i.e.: each rotation would lead to same permuted string). To overcome this, the original string will consist of uppercase letters followed by a single period('.'), this will define the initial rotation.
输入解释
The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format:
One line with the compressed string.This string will consist of uppercase letters, numbers and a single period, and will be a valid block compressed string. The length of the original string that resulted in the compressed one will be no more then 1000000 characters.
输出解释
For every test case in the input, the output should contain a single line with the decompressed string.
输入样例
3
NILDE.E
N13.E13
LRSGORTNOMOMAIOSROC2.GAPTE2NS
输出样例
LEIDEN.
ENENENENENENENENENENENENEN.
PROGRAMMINGCONTESTSARESOCOOL.

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3058

最后修改于 2020-10-29T06:51:28+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536