結果
| 問題 | 
                            No.3108 Luke or Bishop
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-04-19 00:23:00 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 31 ms / 2,000 ms | 
| コード長 | 504 bytes | 
| コンパイル時間 | 459 ms | 
| コンパイル使用メモリ | 11,904 KB | 
| 実行使用メモリ | 10,240 KB | 
| 最終ジャッジ日時 | 2025-04-19 00:23:02 | 
| 合計ジャッジ時間 | 2,059 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 26 | 
ソースコード
def rook_moves(gx, gy):
    if gx == 0 and gy == 0:
        return 0
    if gx == 0 or gy == 0:
        return 1
    return 2
def bishop_moves(gx, gy):
    if (gx + gy) % 2 != 0:
        return float('inf')  # không thể đến được
    if gx == 0 and gy == 0:
        return 0
    if abs(gx) == abs(gy):
        return 1
    return 2
def main():
    gx, gy = map(int, input().split())
    ans = min(rook_moves(gx, gy), bishop_moves(gx, gy))
    print(ans)
if __name__ == "__main__":
    main()