結果

問題 No.3680 セグメント釣り
コンテスト
ユーザー triangle_coder
提出日時 2026-09-02 15:26:45
言語 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  
実行時間 267 ms / 2,000 ms
+ 226µs
コード長 2,625 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,061 ms
コンパイル使用メモリ 379,376 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-09-05 12:48:12
合計ジャッジ時間 9,856 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
using namespace atcoder;
typedef pair<ll,ll> pll;
ll p = 998244353;
ll INF = 2000000000000000010;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

void yn(bool a){
  if(a){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

ll mex(const vector<ll>& a){
  ll n = (ll)a.size();
  vector<int> b(n+1,0);
  for(ll i = 0;i<n;i++){
    if(a[i] < n && a[i] >= 0){
      b[a[i]]++;
    }
  }
  for(ll i = 0;i<n+1;i++){
    if(b[i] == 0){
      return i;
    }
  }
  return 0;
}

vector<ll> two(64,1);
void init() {
    std::cout << std::fixed << std::setprecision(10);
    for(ll i = 1;i<64;i++){
      two.at(i) = two.at(i-1)*2;
    }
}


vector<vector<ll>> vec_seki(const vector<vector<ll>>& a,const vector<vector<ll>>& b,ll p){
  if(a.size() == 0){
    return {};
  }
  assert(a[0].size() == b.size());
  assert(p != 0);
  vector<vector<ll>> ans(a.size(),vector<ll>(b[0].size(),0));
  for(ll i = 0;i<(ll)a.size();i++){
    for(ll k = 0;k<(ll)a[0].size();k++){
      for(ll j = 0;j<(ll)b[0].size();j++){
        ans[i][j] = (ans[i][j]+a[i][k] * b[k][j])%p;
      }
    }
  }
  return ans;
}



template<class T>
vector<pair<T,ll>> runlength(const vector<T>& vec){
  vector<pair<T,ll>> ret;
  if(vec.size()==0){
    return ret;
  }
  pair<T,ll> temp;
  temp.first = vec[0];
  temp.second = 1;
  ret.push_back(temp);
  T mae = vec[0];
  for(ll i = 1;i<(ll)vec.size();i++){
    if(vec[i] != mae){
      temp.first = vec[i];
      temp.second = 1;
      ret.push_back(temp);
      mae = vec[i];
    }
    else{
      ret[ret.size()-1].second++;
    }
  }
  return ret;
}

ll bintoll(const string& S){
  ll ret = 0;
  ll n = (ll)S.size();
  for(ll i = 0;i<n;i++){
    if(S[i] == '1'){
      ret += 1LL<<(n-1-i);
    }
  }
  return ret;
}

string lltobin(const ll N){
    if(N==0) return "0";
    string S;
    ll Nco = N;
    while(Nco!= 0){
        S += char('0' + (Nco&1));
        Nco >>= 1;
    }
    reverse(S.begin(),S.end());
    return S;
}

void solve(){
  ll sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  ll cost = 2e18;
  for(ll i = 0;i<=60;i++){
    cost = min(cost,abs(i-sy) + abs(i-ty) + abs((sx>>i) - (tx>>i)));
  }
  if(sy >= 60 || ty >= 60){
    cost = abs(sy-ty);
  }
  cout << cost << endl;
}

int main() {
  init();

  ll T;
  cin >> T;
  while(T--)solve();

  


  
  // ここにプログラムを追記
}
0