A9662 | A Lot of Games
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of $n$ non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the end of the word, the resulting word must be prefix of at least one string from the group. A player loses if he cannot move.
Andrew and Alex decided to play this game $k$ times. The player who is the loser of the $i$ -th game makes the first move in the $(i+1)$ -th game. Guys decided that the winner of all games is the player who wins the last ( $k$ -th) game. Andrew and Alex already started the game. Fedor wants to know who wins the game if both players will play optimally. Help him.
Given a group of $n$ non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the end of the word, the resulting word must be prefix of at least one string from the group. A player loses if he cannot move.
Andrew and Alex decided to play this game $k$ times. The player who is the loser of the $i$ -th game makes the first move in the $(i+1)$ -th game. Guys decided that the winner of all games is the player who wins the last ( $k$ -th) game. Andrew and Alex already started the game. Fedor wants to know who wins the game if both players will play optimally. Help him.
输入格式
The first line contains two integers, $n$ and $k$ ( $1<=n<=10^{5}$ ; $1<=k<=10^{9}$ ).
Each of the next $n$ lines contains a single non-empty string from the given group. The total length of all strings from the group doesn't exceed $10^{5}$ . Each string of the group consists only of lowercase English letters.
Each of the next $n$ lines contains a single non-empty string from the given group. The total length of all strings from the group doesn't exceed $10^{5}$ . Each string of the group consists only of lowercase English letters.
输出格式
If the player who moves first wins, print "First", otherwise print "Second" (without the quotes).
输入输出样例
输入 #1
2 3 a b
输出 #1
First
输入 #2
3 1 a b c
输出 #2
First
输入 #3
1 2 ab
输出 #3
Second
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted