結果
| 問題 | No.3108 Luke or Bishop |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-18 21:01:25 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 478 bytes |
| 記録 | |
| コンパイル時間 | 158 ms |
| コンパイル使用メモリ | 12,160 KB |
| 実行使用メモリ | 10,240 KB |
| 最終ジャッジ日時 | 2025-04-18 21:01:27 |
| 合計ジャッジ時間 | 1,904 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 |
ソースコード
def rook_moves(x, y):
if x == 0 and y == 0:
return 0
elif x == 0 or y == 0:
return 1
else:
return 2
def bishop_moves(x, y):
if x == 0 and y == 0:
return 0
if (x + y) % 2 != 0:
return float('inf') # unreachable
if x == y or x == -y:
return 1
return 2
# Read input
import sys
x, y = map(int, sys.stdin.read().split())
# Output minimum number of moves
print(min(rook_moves(x, y), bishop_moves(x, y)))