結果

問題 No.2285 Make A Unit Square
ユーザー t98slidert98slider
提出日時 2023-04-28 22:34:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 1,848 ms
コンパイル使用メモリ 170,884 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 07:25:05
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 23 ms
4,376 KB
testcase_03 AC 29 ms
4,380 KB
testcase_04 AC 18 ms
4,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