CF455B.A Lot of Games

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

安德鲁、费奥多尔和亚历克斯是三位富有创造力的人。现在,他们发明了一款面向两名玩家的字符串游戏。

给定一组包含 nn 个非空字符串的集合。在游戏过程中,两名玩家共同构造一个单词,初始时该单词为空。玩家轮流进行操作:在自己的回合中,玩家必须在当前单词末尾添加一个字母,使得得到的新单词至少是给定集合中某个字符串的前缀。若某玩家无法进行合法操作,则该玩家判负。

安德鲁和亚历克斯决定将此游戏进行 kk 轮。第 ii 轮的失败者将在第 (i+1)(i+1) 轮中率先行动。两人约定:最终的获胜者为第 kk(即最后一)轮的胜者。目前,安德鲁和亚历克斯已开始游戏。费奥多尔想知道:若双方均以最优策略进行游戏,最终谁将获胜?请帮助他解答。

输入格式

The first line contains two integers, n and k (1 ≤ n ≤ 105; 1 ≤ k ≤ 109).

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 105. Each string of the group consists only of lowercase English letters.

第一行包含两个整数 nn 和 kk(1≤n≤1051 \leq n \leq 10^5;1≤k≤1091 \leq k \leq 10^9)。

接下来的 nn 行中,每行包含给定组中的一个非空字符串。该组中所有字符串的总长度不超过 10510^5。组中的每个字符串仅由小写英文字母组成。

输出格式

If the player who moves first wins, print "First", otherwise print "Second" (without the quotes).

如果先手玩家获胜,则输出 "First",否则输出 "Second"(不带引号)。

输入输出样例

  • 输入#1

    2 3
    a
    b

    输出#1

    First
  • 输入#2

    3 1
    a
    b
    c

    输出#2

    First
  • 输入#3

    1 2
    ab

    输出#3

    Second

输入解题思路,AI测评打分。不知道怎么写?

首页