結果

問題 No.715 集合と二人ゲーム
ユーザー 0w10w1
提出日時 2018-09-17 11:14:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 923 bytes
コンパイル時間 4,081 ms
コンパイル使用メモリ 208,512 KB
実行使用メモリ 4,992 KB
最終ジャッジ日時 2023-09-25 09:18:24
合計ジャッジ時間 8,522 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 5 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 7 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 9 ms
4,376 KB
testcase_20 AC 9 ms
4,380 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 9 ms
4,376 KB
testcase_23 AC 10 ms
4,380 KB
testcase_24 AC 10 ms
4,380 KB
testcase_25 AC 11 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 11 ms
4,376 KB
testcase_28 AC 12 ms
4,376 KB
testcase_29 AC 12 ms
4,380 KB
testcase_30 AC 11 ms
4,376 KB
testcase_31 AC 10 ms
4,376 KB
testcase_32 AC 9 ms
4,376 KB
testcase_33 AC 11 ms
4,376 KB
testcase_34 AC 9 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 64 ms
4,992 KB
testcase_51 AC 65 ms
4,884 KB
testcase_52 AC 63 ms
4,832 KB
testcase_53 AC 62 ms
4,824 KB
testcase_54 AC 62 ms
4,940 KB
testcase_55 AC 64 ms
4,828 KB
testcase_56 AC 62 ms
4,936 KB
testcase_57 AC 58 ms
4,824 KB
testcase_58 WA -
testcase_59 AC 64 ms
4,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int MAXN = 70;

int sg[MAXN];
int dfs(int x) {
  if (x < 0) return 0;
  if (~sg[x]) return sg[x];
  set<int> bag;
  if (x == 1) bag.emplace(dfs(x - 1));
  else bag.emplace(dfs(x - 2));
  for (int i = 1; i + 1 < x; ++i) bag.emplace(dfs(i - 1) ^ dfs(x - (i + 1) - 1));
  for (int i = 0; ; ++i) if (!bag.count(i)) return sg[x] = i;
}

signed main() {
  memset(sg, 0xff, sizeof(sg));
  sg[0] = 0;

  auto get_sg = [&](int n) {
    if (n < 35) return dfs(n);
    int t = n - 35;
    return dfs(35 + t % 34);
  };

  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int j = i + 1;
    while (j < N && A[j] == A[j - 1] + 1) ++j;
    ans ^= get_sg(j - i) % 6;
    i = j - 1;
  }
  cout << (ans == 0 ? "Second" : "First") << endl;
}
0