結果
| 問題 | No.3679 なんかでっかい虫リターンズ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 13:25:07 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 91 ms / 2,000 ms |
| + 419µs | |
| コード長 | 672 bytes |
| 記録 | |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 95,948 KB |
| 実行使用メモリ | 84,864 KB |
| 最終ジャッジ日時 | 2026-09-05 13:25:11 |
| 合計ジャッジ時間 | 3,578 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
import itertools
from functools import cache
import sys
sys.setrecursionlimit(10 ** 9)
import math
from collections import Counter, deque
input = lambda: sys.stdin.readline().rstrip()
mod = 998244353
h, w = map(int, input().split())
a, b = map(int, input().split())
a -= 1
b -= 1
r1, c1, r2, c2 = map(int, input().split())
r1 -= 1
c1 -= 1
r2 -= 1
c2 -= 1
p, q = map(int, input().split())
p -= 1
q -= 1
ans = 10 ** 10
ret = abs(p - a) + abs(q - b)
for nowr in range(r1, r2 + 1):
for nowc in range(c1, c2 + 1):
approach = abs(a - nowr) + abs(b - nowc)
dispose = abs(nowr - p) + abs(nowc - q)
ans = min(ans, approach + dispose + ret)
print(ans)