結果

問題 No.715 集合と二人ゲーム
ユーザー 0w10w1
提出日時 2018-09-17 11:17:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 927 bytes
コンパイル時間 2,557 ms
コンパイル使用メモリ 208,444 KB
実行使用メモリ 5,436 KB
最終ジャッジ日時 2023-09-25 09:18:45
合計ジャッジ時間 5,973 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 8 ms
4,376 KB
testcase_03 AC 20 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 23 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 22 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 17 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 23 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 20 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 20 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 17 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 26 ms
4,380 KB
testcase_25 AC 20 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 17 ms
4,376 KB
testcase_28 AC 14 ms
4,376 KB
testcase_29 WA -
testcase_30 AC 10 ms
4,376 KB
testcase_31 WA -
testcase_32 AC 8 ms
4,376 KB
testcase_33 WA -
testcase_34 AC 9 ms
4,376 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 2 ms
4,380 KB
testcase_39 AC 2 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,384 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 61 ms
4,932 KB
testcase_59 AC 63 ms
4,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int MAXN = 1000;

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