結果

問題 No.2521 Don't be Same
ユーザー GOTKAKOGOTKAKO
提出日時 2023-10-28 00:05:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 1,784 bytes
コンパイル時間 2,271 ms
コンパイル使用メモリ 202,256 KB
実行使用メモリ 24,516 KB
平均クエリ数 9.89
最終ジャッジ日時 2023-10-28 00:05:47
合計ジャッジ時間 6,111 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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