#abc278f. F - Shiritori
F - Shiritori
Score : points
问题描述
给定 个字符串 。其中, 是一个长度不超过 10 的非空小写英文字符组成的字符串,并且这些字符串两两不相同。
太郎一号和次郎二号玩一个单词接龙游戏。在这个游戏中,两位玩家交替进行回合,由太郎一号先行。在每个玩家的回合中,玩家选择一个整数 ,该整数必须满足以下两个条件:
- 自游戏开始以来, 与两位玩家之前所选择的所有整数都不同;
- 当前是游戏的第一回合,或者 的最后一个字符等于 的第一个字符,其中 是上一回合所选择的整数。
如果玩家无法选择一个符合上述条件的整数,则该玩家输掉比赛;另一玩家获胜。
请判断当两位玩家均采取最优策略时,哪位玩家将会赢得比赛。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given strings . is a non-empty string of length at most consisting of lowercase English letters, and the strings are pairwise distinct.
Taro the First and Jiro the Second play a word-chain game. In this game, the two players take alternating turns, with Taro the First going first. In each player's turn, the player chooses an integer , which should satisfy the following two conditions:
- is different from any integer chosen by the two players so far since the game started;
- the current turn is the first turn of the game, or the last character of equals the first character of , where is the last integer chosen.
The player who is unable to choose a conforming loses; the other player wins.
Determine which player will win if the two players play optimally.
Constraints
- is an integer.
- is a non-empty string of length at most consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
Output
Print First
if Taro the First wins when the two players play optimally; print Second
if Jiro the Second wins.
Sample Input 1
6
enum
float
if
modint
takahashi
template
Sample Output 1
First
For example, the game progresses as follows. Note that the two players may not be playing optimally in this example.
- Taro the First chooses .
if
. - Jiro the Second chooses .
float
, and the last character ofif
equals the first character offloat
. - Taro the First chooses .
takahashi
, and the last character offloat
equals the first character oftakahashi
. - Jiro the Second is unable to choose such that starts with
i
, so he loses.
In this case, Taro the First wins.
Sample Input 2
10
catch
chokudai
class
continue
copy
exec
havoc
intrinsic
static
yucatec
Sample Output 2
Second
Sample Input 3
16
mnofcmzsdx
lgeowlxuqm
ouimgdjxlo
jhwttcycwl
jbcuioqbsj
mdjfikdwix
jhvdpuxfil
peekycgxco
sbvxszools
xuuqebcrzp
jsciwvdqzl
obblxzjhco
ptobhnpfpo
muizaqtpgx
jtgjnbtzcl
sivwidaszs
Sample Output 3
First
update @ 2024/3/10 11:43:03