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

建议使用的浏览器:

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

5442:Favorite Donut

题目描述
Lulu has a sweet tooth. Her favorite food is ring donut. Everyday she buys a ring donut from the same bakery. A ring donut is consists of $n$ parts. Every part has its own sugariness that can be expressed by a letter from $a$ to $z$ (from low to high), and a ring donut can be expressed by a string whose i-th character represents the sugariness of the $i-th$ part in clockwise order. Note that $z$ is the sweetest, and two parts are equally sweet if they have the same sugariness.

Once Lulu eats a part of the donut, she must continue to eat its uneaten adjacent part until all parts are eaten. Therefore, she has to eat either clockwise or counter-clockwise after her first bite, and there are $2n$ ways to eat the ring donut of $n$ parts. For example, Lulu has $6$ ways to eat a ring donut $abc$: $abc, bca, cab, acb, bac, cba$. Lulu likes eating the sweetest part first, so she actually prefer the way of the greatest lexicographic order. If there are two or more lexicographic maxima, then she will prefer the way whose starting part has the minimum index in clockwise order. If two ways start at the same part, then she will prefer eating the donut in clockwise order. Please compute the way to eat the donut she likes most.
输入解释
First line contain one integer $T, T \leq 20$, which means the number of test case.

For each test case, the first line contains one integer $n, n \leq 20000$, which represents how many parts the ring donut has. The next line contains a string consisted of $n$ lowercase alphabets representing the ring donut.
输出解释
You should print one line for each test case, consisted of two integers, which represents the starting point (from $1$ to $n$) and the direction ($0$ for clockwise and $1$ for counterclockwise).
输入样例
2
4
abab
4
aaab
输出样例
2 0
4 0
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5442

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

共提交 0

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