結果

問題 No.3680 セグメント釣り
コンテスト
ユーザー Kude
提出日時 2026-09-05 13:27:11
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 267 ms / 2,000 ms
+ 765µs
コード長 423 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 232 ms
コンパイル使用メモリ 95,956 KB
実行使用メモリ 85,760 KB
最終ジャッジ日時 2026-09-05 13:27:28
合計ジャッジ時間 7,296 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

for _ in range(int(input())):
    sx, sy, tx, ty = map(int, input().split())
    if sx > tx:
        sx, sy, tx, ty = tx, ty, sx, sy
    cost = abs(sy - ty)
    sy = ty = max(sy, ty)
    if sy > 60:
        sx = tx = 0
    else:
        sx = sx >> sy
        tx = tx >> ty
    ans = cost + tx - sx
    while tx != sx:
        cost += 2
        sx >>= 1
        tx >>= 1
        ans = min(ans, cost + tx - sx)
    print(ans)
0