結果

問題 No.2213 Neq Move
ユーザー ShirotsumeShirotsume
提出日時 2023-01-15 20:21:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 76,556 KB
最終ジャッジ日時 2023-09-21 21:57:08
合計ジャッジ時間 1,441 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,376 KB
testcase_01 AC 103 ms
76,556 KB
testcase_02 AC 103 ms
76,344 KB
testcase_03 AC 106 ms
76,096 KB
testcase_04 AC 101 ms
76,508 KB
testcase_05 AC 103 ms
76,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

def solve():
    a, b, c, d = mi()
    if a > b:
        a, b = b, a
        c, d = d, c
    if a <= c and b <= d and c < d:
        print(c - a + d - b)
    elif a <= c and b <= d and c > d:
        print(1 + d + (c - a))
    elif a > c and b > d:
        print(2 + c + d)
    elif a <= c and b > d and c < d:
        if a == 1:
            print(3 + c + d)
        else:
            print(2 + c + d)
    elif a <= c and b > d and c > d:
        print(c - a + 1 + d)
    elif a > c and b <= d and c < d:
        print(1 + c + d - b)
    elif a > c and b <= d and c > d:
        print(2 + c + d)
    else:
        raise Exception

for _ in range(ii()):
    solve()
0