結果

問題 No.715 集合と二人ゲーム
ユーザー drken1215
提出日時 2025-05-13 04:13:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 3,362 bytes
コンパイル時間 2,485 ms
コンパイル使用メモリ 204,232 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-05-13 04:13:33
合計ジャッジ時間 8,284 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 39 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class S, class T> inline bool chmax(S &a, T b) { return (a < b ? a = b, 1 : 0); }
template<class S, class T> inline bool chmin(S &a, T b) { return (a > b ? a = b, 1 : 0); }

using pint = pair<int, int>;
using pll = pair<long long, long long>;
using tint = array<int, 3>;
using tll = array<long long, 3>;
using fint = array<int, 4>;
using fll = array<long long, 4>;
using vint = vector<int>;
using vll = vector<long long>;
using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using int128 = __int128;
using u128 = unsigned __int128;
template <class T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define REP(i, a) for (long long i = 0; i < (long long)(a); i++)
#define REP2(i, a, b) for (long long i = a; i < (long long)(b); i++)
#define RREP(i, a) for (long long i = (a)-1; i >= (long long)(0); --i)
#define RREP2(i, a, b) for (long long i = (b)-1; i >= (long long)(a); --i)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define ALL(x) x.begin(), x.end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

// debug stream
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for (auto it : P) { s << "<" << it << "> "; } return s; }
template<class T> ostream& operator << (ostream &s, multiset<T> P)
{ for (auto it : P) { s << "<" << it << "> "; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for (auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s; }


int main() {
    int M = 1110;
    vector<int> dp(M, 0);
    dp[0] = 0;
    dp[1] = 1;
    REP2(n, 2, M) {
        set<int> S;
        if (n-2 >= 0) S.insert(dp[n-2]);
        if (n-3 >= 0) S.insert(dp[n-3]);
        REP2(j, 1, n-3) {
            int k = n-3-j;
            S.insert(dp[j] ^ dp[k]);
        }
        int mex = 0;
        while (S.count(mex)) mex++;
        dp[n] = mex;

        // if (mex >= 9) {
        //cout << n << ": " << dp[n] << "(" << S << ")" << endl;
        // }

        // if (n >= 34 && dp[n] != dp[n-34]) {
        //     cout << n << ": " << dp[n] << ", " << dp[n-34] << endl;
        // }
    }


    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i]; 
    sort(A.begin(), A.end());
    REP(i, N) A[i] -= i;

    ll grundy = 0;
    for (int i = 0; i < N; ) {
        int j = i;
        while (j < N && A[j] == A[i]) j++;
        int n = j - i;

        int g = n;
        if (n > 100) g = n % 34 + 114;
        grundy ^= dp[g];
        

        //COUT(j-i);
        i = j;
    }
    if (grundy) cout << "First" << endl;
    else cout << "Second" << endl;
}
0