結果

問題 No.3108 Luke or Bishop
コンテスト
ユーザー nhtloc
提出日時 2025-11-26 02:29:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 455 bytes
コンパイル時間 1,846 ms
コンパイル使用メモリ 194,484 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-11-26 02:29:25
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
    long long Gx, Gy;
    cin >> Gx >> Gy;

    int rook_steps = (Gx == 0 || Gy == 0) ? 1 : 2;
    int bishop_steps;

    if (Gx == 0 && Gy == 0) bishop_steps = 0;
    else if (abs(Gx) == abs(Gy)) bishop_steps = 1;
    else if ((Gx + Gy) % 2 == 0) bishop_steps = 2;
    else bishop_steps = 1e9; // không thể đến được

    cout << min(rook_steps, bishop_steps) << endl;
    return 0;
}
0