結果

問題 No.715 集合と二人ゲーム
ユーザー rpy3cpprpy3cpp
提出日時 2018-08-11 22:08:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,930 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 174,524 KB
実行使用メモリ 5,352 KB
最終ジャッジ日時 2023-10-24 14:07:41
合計ジャッジ時間 4,681 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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() - 1;
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