結果

問題 No.715 集合と二人ゲーム
コンテスト
ユーザー rpy3cpp
提出日時 2018-08-11 21:29:21
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 911 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,112 ms
コンパイル使用メモリ 187,740 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-04-11 11:24:10
合計ジャッジ時間 5,125 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

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);
    vector<int> g = {0, 3, 1, 2};
    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 == 1){
            grundy ^= 1;
        }else{
            grundy ^= g[m % 4];
        }
    }
    if (grundy == 0){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
    return 0;
}
0