結果

問題 No.2521 Don't be Same
ユーザー FplusFplusFFplusFplusF
提出日時 2023-10-27 23:14:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 3,301 bytes
コンパイル時間 2,192 ms
コンパイル使用メモリ 202,156 KB
実行使用メモリ 24,624 KB
平均クエリ数 10.54
最終ジャッジ日時 2023-10-27 23:14:24
合計ジャッジ時間 6,221 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x,y;
    cin >> x >> y;
    if(abs(x-y)==1&&max(x,y)%2==0){
        cout << "Second\n";
        cout.flush();
        while(true){
            char c;
            cin >> c;
            if(c=='C'||c=='D') return 0;
            if(c=='A'){
                ll i,j;
                cin >> i >> j;
                if(i==1) x-=j;
                if(i==2) y-=j;
            }
            if(c=='B'){
                x=0;
                y=0;
            }
            if(x==y){
                x=0;
                y=0;
                cout << "B\n";
                cout.flush();
            }else{
                ll i=-1,j=-1;
                if(x==0){
                    i=2;
                    j=y;
                }else if(y==0){
                    i=1;
                    j=x;
                }else if(x<y){
                    if(x%2==0){
                        i=2;
                        j=y-(x-1);
                    }else{
                        i=2;
                        j=y-(x+1);
                    }
                }else{
                    if(y%2==0){
                        i=1;
                        j=x-(y-1);
                    }else{
                        i=1;
                        j=x-(y+1);
                    }
                }
                if(i==1) x-=j;
                if(i==2) y-=j;
                cout << "A " << i << ' ' << j << '\n';
                cout.flush();
            }
        }
    }else{
        cout << "First\n";
        cout.flush();
        while(true){
            if(x==y){
                x=0;
                y=0;
                cout << "B\n";
                cout.flush();
            }else{
                ll i=-1,j=-1;
                if(x==0){
                    i=2;
                    j=y;
                }else if(y==0){
                    i=1;
                    j=x;
                }else if(x<y){
                    if(x%2==0){
                        i=2;
                        j=y-(x-1);
                    }else{
                        i=2;
                        j=y-(x+1);
                    }
                }else{
                    if(y%2==0){
                        i=1;
                        j=x-(y-1);
                    }else{
                        i=1;
                        j=x-(y+1);
                    }
                }
                if(i==1) x-=j;
                if(i==2) y-=j;
                cout << "A " << i << ' ' << j << '\n';
                cout.flush();
            }
            char c;
            cin >> c;
            if(c=='C'||c=='D') return 0;
            if(c=='A'){
                ll i,j;
                cin >> i >> j;
                if(i==1) x-=j;
                if(i==2) y-=j;
            }
            if(c=='B'){
                x=0;
                y=0;
            }
        }
    }
}
0