結果

問題 No.2213 Neq Move
ユーザー tktk_snsntktk_snsn
提出日時 2023-02-10 22:33:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 1,438 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 85,140 KB
最終ジャッジ日時 2023-09-21 23:44:29
合計ジャッジ時間 2,747 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 224 ms
84,112 KB
testcase_01 AC 233 ms
85,000 KB
testcase_02 AC 235 ms
85,016 KB
testcase_03 AC 231 ms
84,992 KB
testcase_04 AC 229 ms
85,140 KB
testcase_05 AC 229 ms
84,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import os
import inspect
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

if os.getenv("TKTKLOCAL", False):
    def debug(*arg, sep=" ", end="\n"):
        print(*arg, sep=sep, end=end, file=sys.stderr)

    def debug_indent(*arg, sep=" ", end="\n", indent="    "):
        frame = inspect.currentframe().f_back
        par_func = inspect.getframeinfo(frame).function
        if par_func == "<module>":
            debug(*arg, sep=sep, end=end)
            return

        frame_stack = inspect.stack()
        if len(frame_stack) > 30:
            return

        depth = sum(f.function == par_func for f in frame_stack)
        debug(indent * (depth - 1), end="")
        debug(*arg, sep=sep, end=end)
else:
    def debug(*arg, **kwarg):
        pass

    def debug_indent(*arg, **kwarg):
        pass


def calc():
    A, B, C, D = map(int, input().split())

    if A < B:
        A, B = B, A
        C, D = D, C

    if C > D:
        if A <= C:
            if B <= D:
                return C - A + D - B
            return 1 + (C - A) + D
        else:
            shift_y = abs(max(2, B) - B)
            return shift_y + 3 + (C - 1) + (D - 0)
    else:
        if D >= B:
            shift_y = abs(max(1, B) - B)
            return shift_y + 1 + (C - 0) + (D - B)
        else:
            return 3 + (C - 1) + D



def main():
    T = int(input())
    for _ in range(T):
        print(calc())


main()
0