CF305E.Playing with String

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Two people play the following string game. Initially the players have got some string ss . 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 ss = "abacaba"A player's move is the sequence of actions:

  1. The player chooses one of the available pieces of paper with some string written on it. Let's denote it is tt . Note that initially, only one piece of paper is available.
  2. The player chooses in the string t=t1t2... ttt=t_{1}t_{2}...\ t_{|t|} character in position ii (1<=i<=t)(1<=i<=|t|) such that for some positive integer ll (0<i-l; i+l<=|t|) the following equations hold: ti1=ti+1t_{i-1}=t_{i+1} , ti2=ti+2t_{i-2}=t_{i+2} , ..., til=ti+lt_{i-l}=t_{i+l} .
  3. 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... ti1t_{1}t_{2}...\ t_{i-1} , the second one will contain a string consisting of a single character tit_{i} , the third one contains string ti+1ti+2... ttt_{i+1}t_{i+2}...\ t_{|t|} .

An example of making action (i=4)(i=4) with string ss = «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 ss ( 1<=s<=50001<=|s|<=5000 ). It is guaranteed that string ss 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 ii (1<=i<=s)(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 22 .

In the second sample the first player has no available moves.

首页