結果

問題 No.3679 なんかでっかい虫リターンズ
コンテスト
ユーザー 👑 loop0919
提出日時 2026-07-14 23:07:35
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 63 ms / 2,000 ms
+ 490µs
コード長 470 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 227 ms
コンパイル使用メモリ 95,820 KB
実行使用メモリ 85,076 KB
最終ジャッジ日時 2026-09-05 12:39:36
合計ジャッジ時間 3,282 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def dist(pos1, pos2):
    r1, c1 = pos1
    r2, c2 = pos2
    return abs(r1 - r2) + abs(c1 - c2)


H, W = [int(s) for s in input().split()]
A, B = [int(s) for s in input().split()]
R1, C1, R2, C2 = [int(s) for s in input().split()]
P, Q = [int(s) for s in input().split()]

start = (A, B)
bugs = [(r, c) for r in range(R1, R2 + 1) for c in range(C1, C2 + 1)]
trash = (P, Q)

ans = min(dist(start, bug) + dist(bug, trash) + dist(trash, start) for bug in bugs)
print(ans)
0