結果
| 問題 |
No.3108 Luke or Bishop
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 18:09:03 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 600 bytes |
| コンパイル時間 | 486 ms |
| コンパイル使用メモリ | 11,904 KB |
| 実行使用メモリ | 10,368 KB |
| 最終ジャッジ日時 | 2025-04-19 18:09:06 |
| 合計ジャッジ時間 | 2,391 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 |
ソースコード
def min_moves(gx, gy):
# ルークの手数
if gx == 0 and gy == 0:
rook_moves = 0
elif gx == 0 or gy == 0:
rook_moves = 1
else:
rook_moves = 2
# ビショップの手数
if (gx + gy) % 2 != 0:
bishop_moves = float('inf') # 不可能
elif gx == 0 and gy == 0:
bishop_moves = 0
elif gx == gy or gx == -gy:
bishop_moves = 1
else:
bishop_moves = 2
# 両方のうち最小の手数を返す
return min(rook_moves, bishop_moves)
# 入力例
gx, gy = map(int, input().split())
print(min_moves(gx, gy))