結果

問題 No.3680 セグメント釣り
コンテスト
ユーザー hotaru-ishibashi
提出日時 2026-09-08 11:53:13
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 287 ms / 2,000 ms
+ 434µs
コード長 544 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 64 ms
コンパイル使用メモリ 82,592 KB
実行使用メモリ 84,840 KB
最終ジャッジ日時 2026-09-08 11:53:21
合計ジャッジ時間 6,887 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

inf = 10**19

def solve():
    sx, sy, tx, ty = map(int, input().split())
    if sx > tx:
        sx, sy, tx, ty = tx, ty, sx, sy
    base_cost = abs(sy - ty)
    Y = max(sy, ty)
    up = 0
    ans = 10**18
    # print(Y)
    while True:
        t_len = 1<<(Y+up) if (Y+up) < 60 else inf
        tr = tx // t_len
        tl = sx // t_len
        dist = tr - tl
        # print(up, t_len, dist)
        ans = min(ans, dist + up*2)
        if dist == 0: break
        up += 1

    print(ans + base_cost)

for _ in range(int(input())):
    solve()
0