Problem Statement
There is a string ss of length 33 or greater. No two neighboring characters in ss are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
- Remove one of the characters in ss, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in ss.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
-
3≤|s|≤1053≤|s|≤105
-
ss consists of lowercase English letters.
-
No two neighboring characters in ss are equal.
Input
The input is given from Standard Input in the following format:
ss
Output
If Takahashi will win, print First. If Aoki will win, print Second.
Sample Input 1 Copy
aba
Sample Output 1 Copy
Second
Takahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of ss, would result in ssbecoming aa, with two as neighboring.
大意:从一个任意左右不相邻的字符串中(除去两端)取出一个字符,要保证取出字符后该字符的左右两个字符不相等,每人取一次,最后谁取不了,谁就输;
思路:为了保证自己赢,每一位选手都会拆除对方的圈套,那么他们俩一定能够对抗到最后,这时就要看两端字符是否一样了;
#include<iostream>
using namespace std;
int main(){
string a;
cin>>a;
int n=a.size();
if(a[0]==a[n-1]) //两端字符相等;
{
if(n%2==0) cout<<"First"; //中间有偶数个,最后一个不能取,先取的赢;
else cout<<"Second";
}
else //两端字符不等;
{
if(n%2==0) cout<<"Second"; //中间有偶数个,能全部取完,先取的败;
else cout<<"First";
}
return 0;
}