CF305E.Playing with String
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Two people play the following string game. Initially the players have got some string s . The players move in turns, the player who cannot make a move loses.
Before the game began, the string is written on a piece of paper, one letter per cell.
An example of the initial situation at s = "abacaba"A player's move is the sequence of actions:
- The player chooses one of the available pieces of paper with some string written on it. Let's denote it is t . Note that initially, only one piece of paper is available.
- The player chooses in the string t=t1t2... t∣t∣ character in position i (1<=i<=∣t∣) such that for some positive integer l (0<i-l; i+l<=|t|) the following equations hold: ti−1=ti+1 , ti−2=ti+2 , ..., ti−l=ti+l .
- Player cuts the cell with the chosen character. As a result of the operation, he gets three new pieces of paper, the first one will contain string t1t2... ti−1 , the second one will contain a string consisting of a single character ti , the third one contains string ti+1ti+2... t∣t∣ .
An example of making action (i=4) with string s = «abacaba»Your task is to determine the winner provided that both players play optimally well. If the first player wins, find the position of character that is optimal to cut in his first move. If there are multiple positions, print the minimal possible one.
输入格式
The first line contains string s ( 1<=∣s∣<=5000 ). It is guaranteed that string s only contains lowercase English letters.
输出格式
If the second player wins, print in the single line "Second" (without the quotes). Otherwise, print in the first line "First" (without the quotes), and in the second line print the minimal possible winning move — integer i (1<=i<=∣s∣) .
输入输出样例
输入#1
abacaba
输出#1
First 2
输入#2
abcde
输出#2
Second
说明/提示
In the first sample the first player has multiple winning moves. But the minimum one is to cut the character in position 2 .
In the second sample the first player has no available moves.