結果

問題 No.1034 テスターのふっぴーさん
ユーザー 👑 KazunKazun
提出日時 2021-03-02 18:05:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 530 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 54,548 KB
最終ジャッジ日時 2024-04-14 04:45:29
合計ジャッジ時間 2,587 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,192 KB
testcase_01 AC 40 ms
52,460 KB
testcase_02 AC 40 ms
52,472 KB
testcase_03 AC 40 ms
53,132 KB
testcase_04 AC 37 ms
52,544 KB
testcase_05 AC 36 ms
53,384 KB
testcase_06 AC 37 ms
52,896 KB
testcase_07 AC 37 ms
51,880 KB
testcase_08 AC 37 ms
53,048 KB
testcase_09 AC 37 ms
52,688 KB
testcase_10 AC 37 ms
52,988 KB
testcase_11 AC 37 ms
53,440 KB
testcase_12 AC 37 ms
52,464 KB
testcase_13 AC 38 ms
52,956 KB
testcase_14 AC 38 ms
52,860 KB
testcase_15 AC 38 ms
53,668 KB
testcase_16 AC 37 ms
52,872 KB
testcase_17 AC 37 ms
53,072 KB
testcase_18 AC 36 ms
52,960 KB
testcase_19 AC 37 ms
53,220 KB
testcase_20 AC 40 ms
53,296 KB
testcase_21 AC 39 ms
54,548 KB
testcase_22 AC 39 ms
53,416 KB
testcase_23 AC 39 ms
53,648 KB
testcase_24 AC 39 ms
54,000 KB
testcase_25 AC 38 ms
53,284 KB
testcase_26 AC 38 ms
53,044 KB
testcase_27 AC 39 ms
54,396 KB
testcase_28 AC 39 ms
52,964 KB
testcase_29 AC 39 ms
53,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def dist(p,q):
    return abs(p[0]-q[0])+abs(p[1]-q[1])
Q=int(input())

for _ in range(Q):
    N,I,J=map(int,input().split())

    level=min(I,(N-1)-I,J,(N-1)-J)
    base=4*level*(N-level)

    if level==I:
        stage=0
        x=level
        y=level
    elif level==(N-1)-J:
        stage=1
        x=level
        y=N-1-level
    elif level==(N-1)-I:
        stage=2
        x=N-1-level
        y=N-1-level
    else:
        stage=3
        x=N-1-level
        y=level
    print(base+stage*(N-(2*level+1))+dist((x,y),(I,J)))
0