結果
| 問題 | No.3680 セグメント釣り |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 14:06:00 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 680 ms / 2,000 ms |
| + 571µs | |
| コード長 | 776 bytes |
| 記録 | |
| コンパイル時間 | 3,846 ms |
| コンパイル使用メモリ | 96,200 KB |
| 実行使用メモリ | 87,344 KB |
| 最終ジャッジ日時 | 2026-09-05 14:07:23 |
| 合計ジャッジ時間 | 8,513 ms |
|
ジャッジサーバーID (参考情報) |
judge6_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
t = int(input())
for _ in range(t):
sx, sy, tx, ty = map(int, input().split())
if sy > ty:
sx, sy, tx, ty = tx, ty, sx, sy
ans = 0
ans += (ty - sy)
min_cost = 10**50
if ty >= 300:
min_cost = 0
else:
for i in range(500):
x1 = min(sx, tx)
x2 = max(sx, tx)
cost = (2 * i)
j = i + ty
if x1 // 2**j == x2 // 2**j:
pass
else:
nx = 2**j * ((x1 + 2**j - 1) // 2**j)
if x1 % 2**j != 0:
cost += 1
cost += abs(x2 - nx) // 2**j
min_cost = min(min_cost, cost)
if x1 // 2**j == x2 // 2**j:
break
print(ans + min_cost)