結果

問題 No.2285 Make A Unit Square
ユーザー KKT89KKT89
提出日時 2023-04-29 11:34:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,178 bytes
コンパイル時間 2,570 ms
コンパイル使用メモリ 216,588 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 07:48:37
合計ジャッジ時間 3,141 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 25 ms
5,376 KB
testcase_03 AC 31 ms
5,376 KB
testcase_04 AC 19 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int memo[120];

int grundy(int x) {
    if (x >= 100) {
        return grundy( (x - 60) % 34 + 60);
    }
    else {
        if (memo[x] != -1) return memo[x];
        set<int> mex;
        for (int i = 2; i <= x - 2; ++i) {
            mex.insert(grundy(i) ^ grundy(x-i));
        }
        int g = 0;
        while (mex.find(g) != mex.end()) g++;
        memo[x] = g;
        return g;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    for (int i = 0; i < 120; ++i) {
        memo[i] = -1;
    }
    int q; cin >> q;
    while (q--) {
        int a,b; cin >> a >> b;
        if (grundy(a) ^ grundy(b)) {
            cout << "First" << "\n";
        }
        else {
            cout << "Second" << "\n";
        }
    }
}
0