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

建议使用的浏览器:

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

6032:Judicious Strategy

题目描述
Alice and Bob is now playing a game about strings.
There is a dictionary containing $n$ words (words might be same). Alice choose a lowercase English letter arbitrarily first, but this letter should appear in at least one of these $n$ words. Then Bob choose a lowercase English letter arbitrarily to add it before or after the letter Alice chose. So Bob gets a new string now. This new string should also be a substring (consecutive subsequence) of at least one strings in the dictionary. After that, it's Alice's turn. Alice should do the same thing, choosing a letter and add it before or after the current string, making a new string. At every moment, the string they made should always be a substring of at least one strings in the dictionary. The player who can't operate first lose the game and the other one win.
Besides, each player has a score. The score is calculated by the following rule:
If the string $S$ is now made, the current player will get $score(S)$ points. It means that Alice will score in the first round, then Bob, then Alice...
\begin{eqnarray*}
score(S)=\left[\left(\sum_{i=1}^{|S|}value(S_i)\right)\times\max_{i=1}^{|S|}value(S_i)\right]+occ(S)
\end{eqnarray*}
where

1. $|S|$ means the length of $S$.
2. $value(c)$ represents the value of letter $c$. The score of letter ``a'' is 1, ``b'' is 2, ..., ``z'' is 26.
3. $occ(S)$ means the time that $S$ occurs as a substring in the dictionary, each word is counted just once.

Alice and Bob will play with best strategy. That is to say, they will consider to win first and then maximize their score, after that they will consider to minimize the score of others.
Please determine who will win the game, and report the final scores they will earn during the whole game.
输入解释
The input contains several test cases, no more than 10 test cases.
In each test case, the first line contains an integer $n(1\leq n\leq 30)$, denoting the number of words in the dictionary.
In the next $n$ lines, each line contains a non-empty string $word_i$, denoting a word in the dictionary. The string is composed of lowercase English letters and its length will not exceed 30.
输出解释
For each test case, output a string in the first line. If Alice will win ,output ''Alice'', otherwise output ''Bob''.
Then print two integers $A$ and $B$ in second line, denoting the final score of Alice and Bob.
输入样例
2
aba
abac
3
artem
nik
max
输出样例
Bob
29 35
Alice
2403 1882
来自杭电HDUOJ的附加信息
Recommend

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

源链接: HDU-6032

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

共提交 0

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