ARC064 D - An Ordinary Game

やり直し

D: An Ordinary Game - AtCoder Regular Contest 064 | AtCoder

解説

ゲームが終了する直前に文字列がどうなっているか考えると良い。(頭いいな〜)

  • 両端が同じ時

abab...a

->直前は奇数個

よって与えられた文字列が奇数の時はSecondの勝ち(firstとsecondが文字をとるときの文字列の奇遇は変わらないので)

  • 両端が異なる時

abab...b

->直前は偶数個

よって与えられた文字列が偶数の時はSecondの勝ち

コード

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  string s; cin >> s;
  if(s[0] == s[s.length()-1]) {
    if(s.length() % 2 == 1) puts("Second");
    else puts("First");
  } else {
    if(s.length() % 2 == 0) puts("Second");
    else puts("First");
  }
  return 0;
}