結果
問題 |
No.2213 Neq Move
|
ユーザー |
![]() |
提出日時 | 2023-02-10 22:33:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 1,438 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 82,028 KB |
実行使用メモリ | 79,568 KB |
最終ジャッジ日時 | 2024-07-07 16:40:19 |
合計ジャッジ時間 | 1,261 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 5 |
ソースコード
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()