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

建议使用的浏览器:

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

4110:Jumping Robot

题目描述
Ali invents a jumping robot. This robot is controlled by a program {Di}, which is a finite sequence of non-negative “jumping distances”. The program can’t be changed once the robot is made.
There are L boxes in a line. Each time the robot is placed in one of the boxes, facing left or right, and then it is turned on. It first jumps over D1 boxes, then jumps over D2 boxes ...
Ali writes a capital letter in each box. The robot prints out all the letter it touches, including the initial one. Now he wants to design a program with a length of p, so that for every kind of letters in the boxes, if you carefully choose the initial position and direction of the robot, it can print out a sequence of that letter of length p.
What’s the maximum possible p for the given letters in boxes?
输入解释
The input consists several testcases.
The first line contains 2 integers n (4 <= n <= 8) and L (4 <= L <= 100), represents the number of different capital letters and the number of boxes.
The second line contains a string whose length is exactly L, represents the letters in each box. The string only contains the first n capital letters, and each letter appears at least once in the string.
输出解释
Print an integer, the maximum length of the jumping program.
输入样例
4 15
DABCDDCCBAACBBA
输出样例
3
来自杭电HDUOJ的附加信息
Recommend lcy

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

源链接: HDU-4110

最后修改于 2020-10-25T23:10:19+00:00 由爬虫自动更新

共提交 0

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