結果

問題 No.2213 Neq Move
ユーザー tamatotamato
提出日時 2023-02-10 23:12:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,476 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 75,656 KB
最終ジャッジ日時 2023-09-22 00:16:57
合計ジャッジ時間 1,605 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,352 KB
testcase_01 AC 79 ms
75,656 KB
testcase_02 AC 83 ms
75,212 KB
testcase_03 AC 81 ms
75,320 KB
testcase_04 AC 80 ms
75,544 KB
testcase_05 AC 81 ms
75,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    for _ in range(int(input())):
        a, b, c, d = map(int, input().split())
        if a > c and b > d:
            print(c + d + 2)
        elif a <= c and b <= d:
            if (a - b) * (c - d) > 0:
                print(c - a + d - b)
            else:
                if a < b:
                    print(c - a + d + 1)
                else:
                    print(d - b + c + 1)
        else:
            if (a - b) * (c - d) > 0:
                if a < b:
                    if d >= b:
                        print(1 + d - b + c)
                    else:
                        if a == 1:
                            print(3 + c + d)
                        else:
                            print(2 + c + d)
                else:
                    if c >= a:
                        print(1 + c - a + d)
                    else:
                        if b == 1:
                            print(3 + c + d)
                        else:
                            print(2 + c + d)
            else:
                if a > b:
                    if d >= b:
                        print(1 + d - b + c)
                    else:
                        print(2 + c + d)
                else:
                    if c >= a:
                        print(1 + c - a + d)
                    else:
                        print(2 + c + d)


if __name__ == '__main__':
    main()
0