結果

問題 No.2285 Make A Unit Square
ユーザー t98slidert98slider
提出日時 2023-04-28 22:34:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 1,769 ms
コンパイル使用メモリ 172,748 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 00:01:36
合計ジャッジ時間 2,451 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 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 #

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

/*
a < b としても一般性を失わない
片方が3以下だと先手が負ける
→片方で幅1の正方形を作った方が負け
*/

int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> dp(301);
    for(int i = 3; i <= 300; i++){
        set<int> S;
        for(int j = 2; j < i; j++){
            if(min(j, i - j) <= 1) continue;
            S.insert(dp[j] ^ dp[i - j]);
        }
        if(S.empty()) continue;
        while(S.count(dp[i])) dp[i]++;
    }
    int T;
    cin >> T;
    while(T--){
        int a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        if(a >= 300){
            a %= 34;
            a += 34 * 3;
        } 
        if(b >= 300){
            b %= 34;
            b += 34 * 3;
        } 
        cout << (dp[a] ^ dp[b] ? "First" : "Second") << '\n';
    }
}
0