結果

問題 No.715 集合と二人ゲーム
ユーザー rpy3cpprpy3cpp
提出日時 2018-08-11 22:18:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,926 bytes
コンパイル時間 1,891 ms
コンパイル使用メモリ 174,440 KB
実行使用メモリ 5,280 KB
最終ジャッジ日時 2023-10-24 14:08:01
合計ジャッジ時間 4,451 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

//vector<int> calc_grundy(int n){
//    if (n < 3){
//        return {0, 1, 1};
//    }
//    vector<int> grundy(n + 1, 0);
//    grundy[0] = 0;
//    grundy[1] = 1;
//    grundy[2] = 1;
//    for (int i = 3; i <= n; ++i){
//        vector<bool> used(20, false);
//        used[grundy[i - 2]] = true;
//        used[grundy[i - 3]] = true;
//        for (int j = i - 4; i - 3 - j <= j; --j){
//            used[grundy[j] ^ grundy[i - 3 - j]] = true;
//        }
//        for (int g = 0; g < used.size(); ++g){
//            if (not used[g]){
//                grundy[i] = g;
//                break;
//            }
//        }
//    }
//    return grundy;
//}

const vector<int> g0 = {0, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 0, 5, 2, 2, 3, 3, 0, 1, 1, 3, 0, 2, 1, 1, 0, 4, 5, 2, 7, 4, 0, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 4, 5, 5, 2};
const vector<int> g1 = {3, 3, 0, 1, 1, 3, 0, 2, 1, 1, 0, 4, 5, 3, 7, 4, 8, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 4, 5, 5, 9};
const int head = g0.size();
const int cycle = g1.size();

vector<int> num_split(const vector<int> & As){
    vector<int> result = {};
    int length = 1;
    for (int i = 1; i < As.size(); ++i){
        if (As[i] == As[i - 1] + 1){
            ++length;
        }else{
            result.push_back(length);
            length = 1;
        }
    }
    result.push_back(length);
    return result;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> As(N);
    for (auto & a : As) cin >> a;
    sort(As.begin(), As.end());
    auto chunks = num_split(As);

    int grundy = 0;
    for (auto & m : chunks){
        if (m < head){
            grundy ^= g0[m];
        }else{
            grundy ^= g1[(m - head) % cycle];
        }
    }
    if (grundy == 0){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
    return 0;
}
0