結果

問題 No.715 集合と二人ゲーム
ユーザー 0w10w1
提出日時 2018-09-17 11:19:36
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 2,466 ms
コンパイル使用メモリ 208,720 KB
実行使用メモリ 5,288 KB
最終ジャッジ日時 2023-09-25 09:18:53
合計ジャッジ時間 7,135 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 AC 9 ms
4,376 KB
testcase_03 AC 20 ms
4,380 KB
testcase_04 AC 24 ms
4,376 KB
testcase_05 AC 25 ms
4,376 KB
testcase_06 AC 25 ms
4,376 KB
testcase_07 AC 26 ms
4,376 KB
testcase_08 AC 26 ms
4,380 KB
testcase_09 AC 27 ms
4,376 KB
testcase_10 AC 26 ms
4,380 KB
testcase_11 AC 27 ms
4,376 KB
testcase_12 AC 27 ms
4,380 KB
testcase_13 AC 28 ms
4,380 KB
testcase_14 AC 29 ms
4,376 KB
testcase_15 AC 29 ms
4,376 KB
testcase_16 AC 29 ms
4,380 KB
testcase_17 AC 29 ms
4,376 KB
testcase_18 AC 30 ms
4,376 KB
testcase_19 AC 30 ms
4,380 KB
testcase_20 AC 31 ms
4,376 KB
testcase_21 AC 31 ms
4,380 KB
testcase_22 AC 31 ms
4,376 KB
testcase_23 AC 31 ms
4,380 KB
testcase_24 AC 32 ms
4,376 KB
testcase_25 AC 32 ms
4,376 KB
testcase_26 AC 32 ms
4,376 KB
testcase_27 AC 33 ms
4,376 KB
testcase_28 AC 34 ms
4,376 KB
testcase_29 AC 33 ms
4,380 KB
testcase_30 AC 32 ms
4,376 KB
testcase_31 AC 32 ms
4,380 KB
testcase_32 AC 31 ms
4,376 KB
testcase_33 AC 31 ms
4,376 KB
testcase_34 AC 31 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 84 ms
5,172 KB
testcase_51 AC 83 ms
5,252 KB
testcase_52 AC 82 ms
5,288 KB
testcase_53 AC 82 ms
5,100 KB
testcase_54 AC 82 ms
5,132 KB
testcase_55 AC 82 ms
5,112 KB
testcase_56 AC 80 ms
4,840 KB
testcase_57 AC 76 ms
4,960 KB
testcase_58 AC 82 ms
5,104 KB
testcase_59 AC 83 ms
5,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int MAXN = 2000;

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 < 1000) return dfs(n);
    int t = n - 1000;
    return dfs(1000 + 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);
    i = j - 1;
  }
  cout << (ans == 0 ? "Second" : "First") << endl;
}
0