結果

問題 No.715 集合と二人ゲーム
ユーザー kimiyukikimiyuki
提出日時 2018-07-13 23:19:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,971 bytes
コンパイル時間 2,582 ms
コンパイル使用メモリ 202,484 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-04-17 11:33:49
合計ジャッジ時間 11,496 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 13 ms
5,376 KB
testcase_05 AC 17 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 39 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 65 ms
5,376 KB
testcase_12 AC 83 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 114 ms
5,376 KB
testcase_15 AC 135 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 178 ms
5,376 KB
testcase_19 AC 218 ms
5,376 KB
testcase_20 AC 198 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 284 ms
5,376 KB
testcase_23 AC 296 ms
5,376 KB
testcase_24 AC 347 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 332 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 484 ms
5,376 KB
testcase_30 TLE -
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, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= int(m); -- (i))
#define ALL(x) begin(x), end(x)
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void chmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

int main() {
    // input
    int n; cin >> n;
    vector<int> a(n);
    REP (i, n) cin >> a[i];

    // solve
    sort(ALL(a));
    a.erase(unique(ALL(a)), a.end());
    n = a.size();
    vector<int> b;
    for (int l = 0; l < n; ) {
        int r = l + 1;
        while (r < n and a[r] == a[r - 1] + 1) {
            ++ r;
        }
        b.push_back(r - l);
        l = r;
    }
    int max_b = *max_element(ALL(b));
    vector<int> grundy(max_b + 1);
    grundy[0] = 0;
    REP3 (i, 1, max_b + 1) {
        vector<int> used;
        REP (l, i) {
            int r = i - l - 1;
            used.push_back(grundy[l] ^ grundy[r]);
        }
        sort(ALL(used));
        int & g = grundy[i];
        while (g < used.size() and g == used[g]) {
            ++ g;
        }
    }
    int answer = 0;
    for (int b_i : b) {
        answer ^= grundy[b_i];
    }

    // output
    cout << (answer ? "First" : "Second") << endl;
    return 0;
}
0