結果

問題 No.715 集合と二人ゲーム
ユーザー mamekinmamekin
提出日時 2018-07-13 23:17:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,542 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 112,700 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 05:35:50
合計ジャッジ時間 5,751 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 57 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void solve(vector<int>& grundy)
{
    grundy.assign(68+1, 0);
    grundy[0] = 0;
    grundy[1] = 1;
    grundy[2] = 1;
    for(int i=3; i<=68; ++i){
        set<int> s;
        s.insert(grundy[i-2]);

        int a = 0;
        int b = i - 3;
        while(a <= b){
            s.insert(grundy[a] ^ grundy[b]);
            ++ a;
            -- b;
        }

        for(const int x : s){
            if(grundy[i] != x)
                break;
            ++ grundy[i];
        }
    }
}

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

    vector<int> grundy;
    solve(grundy);

    int i = 0;
    int ans = 0;
    while(i < n){
        int len = 1;
        ++ i;
        while(i < n && v[i] == v[i-1] + 1){
            ++ len;
            ++ i;
        }

        if(len <= 34)
            ans ^= grundy[len];
        else
            ans ^= grundy[34+(len-1)%34+1];
    }
    if(ans == 0)
        cout << "Second" << endl;
    else
        cout << "First" << endl;

    return 0;
}
0