結果

問題 No.715 集合と二人ゲーム
ユーザー finefine
提出日時 2018-07-13 23:24:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,152 bytes
コンパイル時間 1,888 ms
コンパイル使用メモリ 173,464 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 11:36:42
合計ジャッジ時間 5,039 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,248 KB
testcase_01 AC 8 ms
5,376 KB
testcase_02 AC 8 ms
5,376 KB
testcase_03 AC 8 ms
5,376 KB
testcase_04 AC 9 ms
5,376 KB
testcase_05 AC 9 ms
5,376 KB
testcase_06 AC 9 ms
5,376 KB
testcase_07 AC 10 ms
5,376 KB
testcase_08 AC 10 ms
5,376 KB
testcase_09 AC 11 ms
5,376 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 11 ms
5,376 KB
testcase_12 AC 12 ms
5,376 KB
testcase_13 AC 12 ms
5,376 KB
testcase_14 AC 13 ms
5,376 KB
testcase_15 AC 13 ms
5,376 KB
testcase_16 AC 14 ms
5,376 KB
testcase_17 AC 13 ms
5,376 KB
testcase_18 AC 14 ms
5,376 KB
testcase_19 AC 13 ms
5,376 KB
testcase_20 AC 15 ms
5,376 KB
testcase_21 AC 14 ms
5,376 KB
testcase_22 AC 15 ms
5,376 KB
testcase_23 AC 15 ms
5,376 KB
testcase_24 AC 17 ms
5,376 KB
testcase_25 AC 16 ms
5,376 KB
testcase_26 AC 16 ms
5,376 KB
testcase_27 AC 17 ms
5,376 KB
testcase_28 AC 17 ms
5,376 KB
testcase_29 AC 17 ms
5,376 KB
testcase_30 AC 15 ms
5,376 KB
testcase_31 AC 15 ms
5,376 KB
testcase_32 AC 14 ms
5,376 KB
testcase_33 AC 15 ms
5,376 KB
testcase_34 AC 14 ms
5,376 KB
testcase_35 AC 7 ms
5,376 KB
testcase_36 AC 7 ms
5,376 KB
testcase_37 AC 8 ms
5,376 KB
testcase_38 AC 8 ms
5,376 KB
testcase_39 AC 7 ms
5,376 KB
testcase_40 AC 8 ms
5,376 KB
testcase_41 AC 8 ms
5,376 KB
testcase_42 AC 8 ms
5,376 KB
testcase_43 AC 8 ms
5,376 KB
testcase_44 AC 8 ms
5,376 KB
testcase_45 AC 8 ms
5,376 KB
testcase_46 AC 8 ms
5,376 KB
testcase_47 AC 8 ms
5,376 KB
testcase_48 AC 8 ms
5,376 KB
testcase_49 AC 8 ms
5,376 KB
testcase_50 AC 70 ms
5,376 KB
testcase_51 AC 70 ms
5,376 KB
testcase_52 AC 69 ms
5,376 KB
testcase_53 AC 68 ms
5,376 KB
testcase_54 AC 67 ms
5,376 KB
testcase_55 AC 66 ms
5,376 KB
testcase_56 AC 65 ms
5,376 KB
testcase_57 AC 62 ms
5,376 KB
testcase_58 AC 69 ms
5,376 KB
testcase_59 AC 67 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int dp[500001];

int solve(int x) {
    set<int> s;
    s.insert(dp[x - 2]);
    s.insert(dp[x - 3]);
    for (int i = 1; i <= x - 4; i++) {
        s.insert(dp[i] ^ dp[x - i - 3]);
    }
    int res = 0;
    while (s.find(res) != s.end()) res++;
    return dp[x] = res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << "{";
    //cout << 0 << "," << 1 << "," << 1 << "," << 2;
    dp[1] = 1;
    dp[2] = 1;
    dp[3] = 2;
    for (int i = 4; i <= 1000; i++) {
        solve(i);
    }
    //cout << "};" << endl;

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int cnt = 1;
    vector<int> v;
    for (int i = 1; i < n; i++) {
        if (a[i] - a[i - 1] > 1) {
            v.push_back(cnt);
            cnt = 1;
        } else {
            cnt++;
        }
    }
    v.push_back(cnt);
    int hoge = 0;
    for (int x : v) hoge ^= dp[(x <= 1000 ? x : x - (x - 1000 + 33) / 34 * 34)];
    cout << (hoge == 0 ? "Second" : "First") << endl;
    return 0;
}
0