提出 #4811209
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
using VS = vector<string>; using LL = long long;
using VI = vector<int>; using VVI = vector<VI>;
using PII = pair<int, int>; using PLL = pair<LL, LL>;
using VL = vector<LL>; using VVL = vector<VL>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3")
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x)
#endif
const int INF = 1e9; const LL LINF = 1e16;
const LL MOD = 1000000007; const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 }; int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
/* ----- 2019/04/03 Problem: ABC 048 D / Link: http://abc048.contest.atcoder.jp/tasks/abc048_d ----- */
const int sz = 1000;
const int WIN = 1, LOSE = 2;
map<string, int>gamedp;
int f(string s) {
if (SZ(s) <= 2) {
return LOSE;
}
if (gamedp[s])return gamedp[s];
bool gotolose = 0;
FOR(i, 1, SZ(s) - 1) {
string t = "";
FOR(k, 0, SZ(s)) {
if (k == i)continue;
t += string(1, s[k]);
}
bool ok = 1;
FOR(k, 0, SZ(t) - 1) {
if (t[k] == t[k + 1])ok = 0;
}
if (ok)
gotolose |= f(t) == LOSE;
}
return gamedp[s] = (gotolose ? WIN : LOSE);
}
#include<chrono>
#include<random>
struct randgen {
mt19937_64 rng;
randgen() :rng((int)std::chrono::steady_clock::now().time_since_epoch().count()) {}
LL getrand(LL s, LL t) {
return rng() % (t - s) + s;
}
};
void test(int n) {
string s; {
randgen rnd;
FOR(i, 0, n) {
while (true) {
string t = string(1, 'a' + rnd.getrand(0, 4));
if (SZ(s) && s.back() == t.front())continue;
else {
s += t;
break;
}
}
}
}
DD(de(s, SZ(s), s.front() == s.back(), "WL"[f(s) == LOSE]))
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
//FOR(i, 0, 10) {
// test(10);
//}
//FOR(i, 0, 10) {
// test(11);
//}
//cout << "WL"[f("aba") == LOSE] << endl;
//cout << "WL"[f("abc") == LOSE] << endl;
//cout << "WL"[f("abcab") == LOSE] << endl;
string s; cin >> s;
cout << ((s.front()==s.back())^(SZ(s)%2)? "First" : "Second") << endl;
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
D - An Ordinary Game |
| ユーザ |
Yang33 |
| 言語 |
C++14 (GCC 5.4.1) |
| 得点 |
500 |
| コード長 |
2510 Byte |
| 結果 |
AC |
| 実行時間 |
1 ms |
| メモリ |
512 KiB |
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
500 / 500 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
0_00.txt, 0_01.txt, 0_02.txt |
| All |
0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 0_00.txt |
AC |
1 ms |
256 KiB |
| 0_01.txt |
AC |
1 ms |
256 KiB |
| 0_02.txt |
AC |
1 ms |
256 KiB |
| 1_00.txt |
AC |
1 ms |
256 KiB |
| 1_01.txt |
AC |
1 ms |
256 KiB |
| 1_02.txt |
AC |
1 ms |
256 KiB |
| 1_03.txt |
AC |
1 ms |
256 KiB |
| 1_04.txt |
AC |
1 ms |
256 KiB |
| 1_05.txt |
AC |
1 ms |
256 KiB |
| 1_06.txt |
AC |
1 ms |
512 KiB |
| 1_07.txt |
AC |
1 ms |
512 KiB |
| 1_08.txt |
AC |
1 ms |
512 KiB |
| 1_09.txt |
AC |
1 ms |
512 KiB |
| 1_10.txt |
AC |
1 ms |
512 KiB |
| 1_11.txt |
AC |
1 ms |
512 KiB |
| 1_12.txt |
AC |
1 ms |
512 KiB |
| 1_13.txt |
AC |
1 ms |
512 KiB |
| 1_14.txt |
AC |
1 ms |
512 KiB |
| 1_15.txt |
AC |
1 ms |
512 KiB |
| 1_16.txt |
AC |
1 ms |
512 KiB |
| 1_17.txt |
AC |
1 ms |
512 KiB |
| 1_18.txt |
AC |
1 ms |
512 KiB |
| 1_19.txt |
AC |
1 ms |
512 KiB |
| 1_20.txt |
AC |
1 ms |
512 KiB |
| 1_21.txt |
AC |
1 ms |
512 KiB |
| 1_22.txt |
AC |
1 ms |
512 KiB |
| 1_23.txt |
AC |
1 ms |
512 KiB |
| 1_24.txt |
AC |
1 ms |
512 KiB |
| 1_25.txt |
AC |
1 ms |
512 KiB |
| 1_26.txt |
AC |
1 ms |
384 KiB |
| 1_27.txt |
AC |
1 ms |
512 KiB |
| 1_28.txt |
AC |
1 ms |
512 KiB |
| 1_29.txt |
AC |
1 ms |
512 KiB |
| 1_30.txt |
AC |
1 ms |
512 KiB |
| 1_31.txt |
AC |
1 ms |
384 KiB |
| 1_32.txt |
AC |
1 ms |
512 KiB |
| 1_33.txt |
AC |
1 ms |
512 KiB |
| 1_34.txt |
AC |
1 ms |
384 KiB |
| 1_35.txt |
AC |
1 ms |
512 KiB |
| 1_36.txt |
AC |
1 ms |
384 KiB |
| 1_37.txt |
AC |
1 ms |
512 KiB |
| 1_38.txt |
AC |
1 ms |
512 KiB |
| 1_39.txt |
AC |
1 ms |
512 KiB |
| 1_40.txt |
AC |
1 ms |
512 KiB |
| 1_41.txt |
AC |
1 ms |
512 KiB |
| 1_42.txt |
AC |
1 ms |
384 KiB |
| 1_43.txt |
AC |
1 ms |
512 KiB |
| 1_44.txt |
AC |
1 ms |
512 KiB |
| 1_45.txt |
AC |
1 ms |
512 KiB |