結果

問題 No.2521 Don't be Same
ユーザー RubikunRubikun
提出日時 2023-10-27 22:07:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 2,228 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 204,112 KB
実行使用メモリ 24,576 KB
平均クエリ数 10.07
最終ジャッジ日時 2023-10-27 22:07:50
合計ジャッジ時間 5,818 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
24,564 KB
testcase_01 AC 65 ms
24,576 KB
testcase_02 AC 66 ms
24,576 KB
testcase_03 AC 64 ms
24,576 KB
testcase_04 AC 65 ms
24,576 KB
testcase_05 AC 66 ms
24,576 KB
testcase_06 AC 64 ms
24,576 KB
testcase_07 AC 66 ms
24,576 KB
testcase_08 AC 66 ms
24,576 KB
testcase_09 AC 66 ms
24,576 KB
testcase_10 AC 63 ms
24,576 KB
testcase_11 AC 64 ms
24,576 KB
testcase_12 AC 63 ms
24,576 KB
testcase_13 AC 65 ms
24,576 KB
testcase_14 AC 64 ms
24,576 KB
testcase_15 AC 64 ms
24,576 KB
testcase_16 AC 65 ms
24,576 KB
testcase_17 AC 65 ms
24,576 KB
testcase_18 AC 66 ms
24,576 KB
testcase_19 AC 66 ms
24,576 KB
testcase_20 AC 67 ms
24,576 KB
testcase_21 AC 65 ms
24,576 KB
testcase_22 AC 66 ms
24,576 KB
testcase_23 AC 65 ms
24,576 KB
testcase_24 AC 67 ms
24,576 KB
testcase_25 AC 66 ms
24,576 KB
testcase_26 AC 66 ms
24,576 KB
testcase_27 AC 66 ms
24,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;

bool solve(int a,int b){
    if(a==0&&b==0) return false;
    if(a==0||b==0) return true;
    if(a==b) return true;
    
    if(a){
        for(int k=1;k<=a;k++){
            if(!solve(a-k,b)) return true;
        }
    }
    if(b){
        for(int k=1;k<=b;k++){
            if(!solve(a,b-k)) return true;
        }
    }
    return false;
}

int main(){
    
    for(int a=0;a<=10;a++){
        for(int b=0;b<=10;b++){
            //cout<<solve(a,b)<<" ";
        }
        //cout<<endl;
    }
    
    int X,Y;cin>>X>>Y;
    
    auto mov=[&](){
        if(X==Y) cout<<"B"<<endl;
        else if(X==0){
            cout<<"A"<<" "<<2<<" "<<Y<<endl;
            Y=0;
        }
        else if(Y==0){
            cout<<"A"<<" "<<1<<" "<<X<<endl;
            X=0;
        }
        else{
            if(Y%2==0&&X>Y-1){
                cout<<"A"<<" "<<1<<" "<<X-(Y-1)<<endl;
                X=Y-1;
            }
            else if(Y%2==1&&X>Y+1){
                cout<<"A"<<" "<<1<<" "<<X-(Y+1)<<endl;
                X=Y+1;
            }
            else if(X%2==0&&Y>X-1){
                cout<<"A"<<" "<<2<<" "<<Y-(X-1)<<endl;
                Y=X-1;
            }
            else if(X%2==1&&Y>X+1){
                cout<<"A"<<" "<<2<<" "<<Y-(X+1)<<endl;
                Y=X+1;
            }
            else exit(1);
        }
    };
    
    auto wait=[&](){
        char c;cin>>c;
        if(c=='C') exit(0);
        if(c=='D') exit(1);
        if(c=='A'){
            ll a,b;cin>>a>>b;
            if(a==1) X-=b;
            else Y-=b;
        }else{
            X=0;
            Y=0;
        }
    };
    if((X+1==Y&&Y%2==0)||(Y+1==X&&X%2==0)){
        cout<<"Second"<<endl;
        wait();
    }else{
        cout<<"First"<<endl;
    }
    
    while(1){
        mov();
        wait();
    }
}
0