結果

問題 No.715 集合と二人ゲーム
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2018-07-15 11:46:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,348 bytes
コンパイル時間 1,557 ms
コンパイル使用メモリ 171,824 KB
実行使用メモリ 13,952 KB
最終ジャッジ日時 2024-04-23 15:12:34
合計ジャッジ時間 5,957 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/




int N, A[501010];
//---------------------------------------------------------------------------------------------------
int memo[501010];
int g(int x) {
    if (1010 <= x) return g(34 * 101 + x % 34);
    if (0 <= memo[x]) return memo[x];

    if (x == 0) return memo[x] = 0;
    if (x <= 2) return memo[x] = 1;

    set<int> gr;
    gr.insert(g(x - 2));
    gr.insert(g(x - 3));

    if (5 <= x) {
        rep(i, 1, x) {
            int j = x - i - 3;
            if (1 <= j) gr.insert(g(i) ^ g(j));
        }
    }

    int res = 0;
    while (gr.count(res)) res++;
    return memo[x] = res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    sort(A, A + N);

    rep(i, 0, 501010) memo[i] = -1;
    //rep(i, 0, 1010) printf("%d : %d\n", i, g(i));
    
    int L = 0;
    int gr = 0;
    while (L < N) {
        int i = L + 1;
        while (i < N and A[i] <= A[i - 1] + 1) i++;

        int len = A[i - 1] - A[L] + 1;
        gr ^= g(len);
        L = i;
    }

    if (gr == 0) printf("Second\n");
    else printf("First\n");
    
}
0