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

建议使用的浏览器:

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

2307:Necklace Decomposition

题目描述
The set of cyclic rotations of a string are the strings obtained by embedding the string clockwise on a ring, with the first character following on the last, starting at any character position and moving clockwise on the ring until the character preceeding the starting character is reached. A string is a necklace if it is the lexicographically smallest among all its cyclic rotations. For instance, for the string 01011 the cyclic rotations are (10110,01101,11010,10101,01011), and furthermore 01011 is the smallest string and hence, a necklace.
Any string S can be written in a unique way as a concatenation S = T1T2 . . . Tk of necklaces Ti such that Ti+1 < Ti for all i = 1, . . . , k - 1, and TiTi+1 is not a necklace for any i = 1, . . . , k - 1. This representation is called the necklace decomposition of the string S, and your task is to find it.
The relation < on two strings is the lexicographical order and has the usual interpretation: A < B if A is a proper prefix of B or if A is equal to B in the first j - 1 positions but smaller in the jth position for some j. For instance, 001 < 0010 and 1101011 < 1101100
输入解释
On the first line of the input is a single positive integer n, telling the number of test scenarios to follow. Each scenario consists of one line containing a non-empty string of zeros and ones of length at most 100.
输出解释
For each scenario, output one line containing the necklace decomposition of the string. The necklaces should be written as '(' necklace ')'.
输入样例
5
0
0101
0001
0010
11101111011
输出样例
(0)
(0101)
(0001)
(001)(0)
(111)(01111)(011)
来自杭电HDUOJ的附加信息
Recommend zty

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 NCPC2005

源链接: HDU-2307

最后修改于 2020-10-25T22:52:22+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/1000MS(Java/Others) 65536/32768K(Java/Others)