結果

問題 No.3680 セグメント釣り
コンテスト
ユーザー t98slider
提出日時 2026-09-05 13:32:33
言語 C++23
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 57 ms / 2,000 ms
+ 257µs
コード長 727 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,928 ms
コンパイル使用メモリ 331,700 KB
実行使用メモリ 9,764 KB
最終ジャッジ日時 2026-09-05 13:32:43
合計ジャッジ時間 6,306 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T--){
        ll sx, sy, gx, gy;
        cin >> sx >> sy >> gx >> gy;
        if(sx > gx){
            swap(sx, gx);
            swap(sy, gy);
        }
        ll mx = max(sy, gy);
        if(mx >= 62){
            cout << abs(sy - gy) << '\n';
            continue;
        }
        ll ans = 1ll << 62;
        for(ll md = mx; md <= 62; md++){
            ll d = 1ll << md;
            ll dy = abs(md - sy) + abs(md - gy);
            ll x0 = sx / d, x1 = gx / d;
            ans = min(ans, abs(x0 - x1) + dy);
        }
        cout << ans << '\n';
    }
}
0