結果
問題 |
No.3108 Luke or Bishop
|
ユーザー |
|
提出日時 | 2025-04-19 08:00:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 709 bytes |
コンパイル時間 | 1,902 ms |
コンパイル使用メモリ | 192,544 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-04-19 08:00:55 |
合計ジャッジ時間 | 3,021 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long gx, gy; cin >> gx >> gy; // ルークの手数 int rook; if (gx == 0 && gy == 0) { rook = 0; } else if (gx == 0 || gy == 0) { rook = 1; } else { rook = 2; } // ビショップの手数 int bishop; if (gx == 0 && gy == 0) { bishop = 0; } else if (((gx + gy) & 1) != 0) { bishop = INT_MAX; // 到達不可 } else if (llabs(gx) == llabs(gy)) { bishop = 1; } else { bishop = 2; } // 答え int ans = min(rook, bishop); cout << ans << "\n"; return 0; }