結果

問題 No.2521 Don't be Same
ユーザー GOTKAKO
提出日時 2023-10-28 00:05:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,784 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 195,356 KB
最終ジャッジ日時 2025-02-17 16:19:48
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int X,Y; cin >> X >> Y;
    if(abs(X-Y) != 1 || min(X,Y)%2 == 0){
        cout << "First" << endl;
        while(true){
            if(X == Y) cout << "B" << endl;
            else if(Y == 0) cout << "A 1 " << X << endl;
            else if(X == 0) cout << "A 2 " << Y << endl;
            else if(X > Y){
                int plus = 1;
                if(Y%2 == 0) plus = -1;
                cout << "A 1 " << X-(Y+plus) << endl; 
                X -= X-(Y+plus);
            }
            else{
                int plus = 1;
                if(X%2 == 0) plus = -1;
                cout << "A 2 " << Y-(X+plus) << endl;
                Y -= Y-(X+plus);
            }

            char c; cin >> c;
            if(c == 'C' || c == 'D') return 0;

            int w,n; cin >> w >> n;
            if(w == 1) X -= n;
            else Y -= n;
        }       
    }
    else{
        cout << "Second" << endl;
        while(true){
            char c; cin >> c;
            if(c == 'C' || c == 'D') return 0;

            int w,n; cin >> w >> n;
            if(w == 1) X -= n;
            else Y -= n;

            if(X == Y) cout << "B" << endl;
            else if(Y == 0) cout << "A 1 " << X << endl;
            else if(X == 0) cout << "A 2 " << Y << endl;
            else if(X > Y){
                int plus = 1;
                if(Y%2 == 0) plus = -1;
                cout << "A 1 " << X-(Y+plus) << endl;
                X -= X-(Y+plus);
            }
            else{
                int plus = 1;
                if(X%2 == 0) plus = -1;
                cout << "A 2 " << Y-(X+plus) << endl;
                Y -= Y-(X+plus);
            }
        }
    }
}
0