結果
| 問題 |
No.208 王将
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-02-07 09:09:02 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 1,000 ms |
| コード長 | 1,042 bytes |
| コンパイル時間 | 176 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-09-14 06:25:26 |
| 合計ジャッジ時間 | 1,789 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
def main():
x_dst, y_dst = list(map(
int, input().split()
))
x_fu, y_fu = list(map(
int, input().split()
))
# ゴールが対角線上かつ,その通り道に歩がいる場合のみ
# 1回無駄な動きが生じる
move = 0
if x_dst == y_dst:
if x_dst > 0 and y_dst > 0 and x_fu > 0 and y_fu > 0 and x_fu == y_fu and x_dst > x_fu:
move += 1
if x_dst < 0 and y_dst > 0 and x_fu < 0 and y_fu > 0 and x_fu == y_fu and x_dst < x_fu:
move += 1
if x_dst < 0 and y_dst < 0 and x_fu < 0 and y_fu < 0 and x_fu == y_fu and x_dst < x_fu:
move += 1
if x_dst > 0 and y_dst < 0 and x_fu > 0 and y_fu < 0 and x_fu == y_fu and x_dst > x_fu:
move += 1
move += x_dst
print(move)
else:
x_dst_abs, y_dst_abs = abs(x_dst), abs(y_dst)
bigger = max(x_dst_abs, y_dst_abs)
smaller = min(x_dst_abs, y_dst_abs)
move = (bigger - smaller) + smaller
print(move)
main()