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

建议使用的浏览器:

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

6791:Tokitsukaze, CSL and Palindrome Game

题目描述
Tokitsukaze is playing with CSL a game based on a string $S_{1..n}$ which only contains lowercase letters and whose length is $n$.

A string is palindromic if and only if it reads the same backward as forward, such as "madam" and "racecar". Before the game starts, Tokitsukaze will select a palindromic substring of $S$, denoted as $S_{a..b}$, and CSL will select a palindromic substring, denoted as $S_{c..d}$, too.

There is also a string $P$ that is empty at the beginning of the game. Then at every second, a character will be appended to the end of $P$ automatically, where the character is randomly chosen from all possible lowercase letters (i.e. 'a' to 'z'), each with the same probability $\frac{1}{26}$. The game ends when both $S_{a..b}$ and $S_{c..d}$ become substrings of $P$.

Let $E(S_{a..b})$ be the expected length of $P$ when $S_{a..b}$ firstly becomes a substring of $P$, and $E(S_{c..d})$ be the similar expected value for $S_{c..d}$. The winner of the game will be the one with a lower expected value for his or her choice. In case of a tie, when $E(S_{a..b})$ equals to $E(S_{c..d})$, the game is a draw.

Now, they will play this game with the same string $S$ for $q$ times, and Tokitsukaze will inform you of their choices in each game. Can you predict for her the result of each game?
输入解释
There are several test cases.

The first line contains an integer $T$ $(1 \leq T \leq 25)$, denoting the number of test cases. Then follow all the test cases.

For each test case, the first line contains an integer $n$ $(1 \leq n \leq 10^5)$, denoting the length of the string $S$.

The second line contains the string $S$ consisting of only lowercase letters.

The third line contains an integer $q$ $(1 \leq q \leq 10^5)$, denoting the number of games.

In the next $q$ lines, each line contains four integers $a$, $b$, $c$ and $d$ $(1 \leq a \leq b \leq n, 1 \leq c \leq d \leq n)$, representing a game where Tokitsukaze selects $S_{a..b}$ and CSL selects $S_{c..d}$.
输出解释
For each game, output in one line "sjfnb" (without quotes, the same below) if Tokitsukaze will be the winner, or "cslnb" if CSL will, or "draw" in case of a tie. Note that the output characters are case-sensitive.
输入样例
1
7
abbabba
5
1 1 2 2
1 4 4 7
2 3 1 7
1 4 5 6
2 3 3 5
输出样例
draw
draw
sjfnb
cslnb
sjfnb
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6791

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

共提交 0

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