結果

問題 No.3680 セグメント釣り
コンテスト
ユーザー 👑 loop0919
提出日時 2026-06-28 15:20:56
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 489 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 551 ms
コンパイル使用メモリ 21,460 KB
実行使用メモリ 15,788 KB
最終ジャッジ日時 2026-09-05 12:32:34
合計ジャッジ時間 7,274 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 2 -- * 11
権限があれば一括ダウンロードができます

ソースコード

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