結果
| 問題 | No.3680 セグメント釣り |
| コンテスト | |
| ユーザー |
dokukuma
|
| 提出日時 | 2026-09-05 14:18:40 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 626 ms / 2,000 ms |
| + 721µs | |
| コード長 | 1,834 bytes |
| 記録 | |
| コンパイル時間 | 258 ms |
| コンパイル使用メモリ | 95,976 KB |
| 実行使用メモリ | 90,752 KB |
| 最終ジャッジ日時 | 2026-09-05 14:19:19 |
| 合計ジャッジ時間 | 8,017 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
import sys, time, random, heapq, math, itertools, copy
from collections import deque, Counter, defaultdict
#from sortedcontainers import SortedSet, SortedList
from bisect import bisect, bisect_left, bisect_right
import heapq as hq
from functools import cache, cmp_to_key
def debug(*x):print('debug:',*x, file=sys.stderr)
sys.setrecursionlimit(300000)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353
dir = [(0, 1), (0, -1), (1, 0), (-1, 0)]
T = ii()
for _ in range(T):
Sx, Sy, Tx, Ty = mi()
if Sx == Tx:
print(abs(Sy - Ty))
continue
if Sx > Tx:
Sx, Sy, Tx, Ty = Tx, Ty, Sx, Sy
ans = 0
if Sy < Ty:
ans += Ty - Sy
Sy = Ty
elif Ty < Sy:
ans += Sy - Ty
Ty = Sy
output = inf
if Sy < 70:
left_s, right_s = (Sx // pow(2, Sy))*pow(2, Sy), (Sx // pow(2, Sy))*pow(2,Sy) + pow(2, Sy)
else:
left_s, right_s = 0, inf
if Ty < 70:
left_t, right_t = (Tx // pow(2, Ty))*pow(2, Ty), (Tx // pow(2, Ty))*pow(2,Ty) + pow(2, Ty)
else:
left_t, right_t = 0, inf
#debug(left_s, right_s)
#debug(left_t, right_t)
while left_s != left_t:
output = min(output, ans + (left_t - left_s) // pow(2, Sy))
ans += 2
Sy += 1
Ty += 1
if Sy < 70:
left_s, right_s = (Sx // pow(2, Sy))*pow(2, Sy), (Sx // pow(2, Sy))*pow(2,Sy) + pow(2, Sy)
else:
left_s, right_s = 0, inf
if Ty < 70:
left_t, right_t = (Tx // pow(2, Ty))*pow(2, Ty), (Tx // pow(2, Ty))*pow(2,Ty) + pow(2, Ty)
else:
left_t, right_t = 0, inf
#debug(left_s, left_t)
output = min(output, ans)
print(output)
dokukuma