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

建议使用的浏览器:

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

7190:BBQ

题目描述
Today is XllX's birthday. XllX wants to go to barbecue with his good friends. They go to a supermarket and get a lot of food. Then they ride to Laoyingzui, a good place to barbecue outside.

XllX thinks a perfect barbecue string must satisfy the property that it is in a format of $abba$ (just like his name). That is, a perfect barbecue string $s$ satisfies that $s_i=s_{i+3}$, $s_{i+1}=s_{i+2}$ ( $i \equiv 1 \pmod 4$, $len \equiv 0 \pmod 4$ ), the index starts from $1$ . Note that, empty string is a perfect string.

However, XllX is too busy to prepare the barbecue string. It might not be a perfect string. Now you can modify, add or delete one letter in 1 unit of time. Can you transfer the barbecue string into a perfect string in minimum unit of time?
输入解释
Each test contains multiple test cases. The first line contains the number of test cases $(1 \le T \le 12)$. Description of the test cases follows.

Only one string stands for the barbecue string. It is guaranteed that the length of the string is not greater than $10^6$. All the letters of the string is in lowercase.
输出解释
For each test case:

Print one integer in a line --- the minimum unit of time.
输入样例
1
abbba
输出样例
1

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

源链接: HDU-7190

最后修改于 2022-09-15T06:17:16+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 524288/262144K(Java/Others)