結果

問題 No.3680 セグメント釣り
コンテスト
ユーザー 👑 loop0919
提出日時 2026-06-22 23:02:40
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 395 ms / 2,000 ms
+ 751µs
コード長 489 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 234 ms
コンパイル使用メモリ 95,956 KB
実行使用メモリ 86,536 KB
最終ジャッジ日時 2026-09-05 12:31:30
合計ジャッジ時間 6,753 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

INF = 2 * 10**18
LIMIT = 60


def solve(s_x: int, s_y: int, t_x: int, t_y: int) -> int:
    if max(s_y, t_y) >= LIMIT:
        return abs(s_y - t_y)

    ans = INF
    for h in range(max(s_y, t_y), LIMIT + 1):
        dist_x = abs(s_x // 2**h - t_x // 2**h)
        dist_y = (h - s_y) + (h - t_y)

        ans = min(ans, dist_x + dist_y)

    return ans


T = int(input())

for _ in range(T):
    s_x, s_y, t_x, t_y = [int(s) for s in input().split()]
    print(solve(s_x, s_y, t_x, t_y))
0