結果
| 問題 | No.3680 セグメント釣り |
| コンテスト | |
| ユーザー |
bolero
|
| 提出日時 | 2026-09-05 14:16:55 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 258 ms / 2,000 ms |
| + 577µs | |
| コード長 | 1,801 bytes |
| 記録 | |
| コンパイル時間 | 4,256 ms |
| コンパイル使用メモリ | 374,564 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2026-09-05 14:17:52 |
| 合計ジャッジ時間 | 9,265 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
#if __has_include(<pch/all.h>)
#include <pch/all.h>
#else
#include <bits/stdc++.h>
#include <atcoder/all>
#endif
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No")
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
#define REVERSE(v) reverse(v.begin(), v.end())
template <typename Container>
void printVector(const Container &v, char delimiter = ' ')
{
for (auto itr = v.begin(); itr != v.end(); itr++)
{
if (itr != v.begin())
{
cout << delimiter;
}
cout << *itr;
}
cout << endl;
}
template <typename Container>
void printlnVector(const Container &v)
{
printVector(v, '\n');
}
void solve()
{
unsigned long long Sx, Sy, Tx, Ty;
cin >> Sx >> Sy >> Tx >> Ty;
if (Sy > Ty)
{
swap(Sx, Tx);
swap(Sy, Ty);
}
unsigned long long ans = ULONG_LONG_MAX;
// cout << Sx << ", " << Sy << ", " << Tx << ", " << Ty << endl;
// 高さtまで移動する
for (unsigned long long t = Ty; t <= Ty + 60; t++)
{
unsigned long long d_y = t - Sy + t - Ty;
unsigned long long d_x = 0;
if (t >= 61)
{
d_x += 0;
}
else
{
unsigned long long pw = 1ull << t;
unsigned long long s_i = Sx / pw;
unsigned long long t_i = Tx / pw;
d_x += max(s_i, t_i) - min(s_i, t_i);
// cout << " " << s_i << ", " << t_i << endl;
}
// cout << t << ": " << d_y << " " << d_x << endl;
ans = min(ans, d_x + d_y);
}
cout << ans << endl;
}
int main()
{
int T = 1;
cin >> T;
while (T--)
{
solve();
}
return 0;
}
bolero