結果

問題 No.1034 テスターのふっぴーさん
ユーザー FromBooskaFromBooska
提出日時 2023-03-12 20:25:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 1,144 ms
コンパイル使用メモリ 81,584 KB
実行使用メモリ 52,300 KB
最終ジャッジ日時 2023-10-18 10:46:20
合計ジャッジ時間 2,750 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,648 KB
testcase_01 AC 40 ms
51,644 KB
testcase_02 AC 39 ms
51,640 KB
testcase_03 AC 39 ms
51,644 KB
testcase_04 AC 39 ms
51,648 KB
testcase_05 AC 39 ms
51,648 KB
testcase_06 AC 39 ms
51,648 KB
testcase_07 AC 39 ms
51,640 KB
testcase_08 AC 39 ms
51,648 KB
testcase_09 AC 43 ms
51,648 KB
testcase_10 AC 40 ms
51,648 KB
testcase_11 AC 38 ms
51,648 KB
testcase_12 AC 39 ms
51,644 KB
testcase_13 AC 39 ms
51,648 KB
testcase_14 AC 39 ms
51,644 KB
testcase_15 AC 39 ms
51,644 KB
testcase_16 AC 39 ms
51,648 KB
testcase_17 AC 39 ms
51,664 KB
testcase_18 AC 39 ms
51,652 KB
testcase_19 AC 40 ms
51,648 KB
testcase_20 AC 43 ms
52,280 KB
testcase_21 AC 42 ms
52,292 KB
testcase_22 AC 42 ms
52,280 KB
testcase_23 AC 42 ms
52,280 KB
testcase_24 AC 41 ms
52,300 KB
testcase_25 AC 42 ms
52,288 KB
testcase_26 AC 42 ms
52,284 KB
testcase_27 AC 42 ms
52,284 KB
testcase_28 AC 42 ms
52,296 KB
testcase_29 AC 41 ms
52,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# じゃがいもの皮をむくイメージ
# 最初の皮の層は(N-1)*4、次の皮の層は(N-3)*4、、、と続く
# (i, j)が与えられたら第何層の何個目かでわかるはず
# TLEしたのでs配列を計算式にする

Q = int(input())
for q in range(Q):
    n, i, j = map(int, input().split())
    # 第何層か
    i_layer = min(i, n-1-i)
    j_layer = min(j, n-1-j)
    layer = min(i_layer, j_layer)
    s = (layer)*n*4 - 4*layer*2*layer//2
    #s2 = 0
    #for l in range(layer):
    #    s2 += (n-l*2-1)*4
    #print('layer', layer, 's', s, 's2', s2)
    # その中の何番目か、第k層の最初は(k, k)
    idx_in_layer = 0
    if i == layer:
        idx_in_layer = j-layer
    elif i == n-1-layer:
        idx_in_layer = (n-(layer*2+1))*2 + (n-1-layer) - j
    elif j == n-1-layer:
        idx_in_layer = (n-(layer*2+1)) + i - layer
    elif j == layer:
        idx_in_layer = (n-(layer*2+1))*3 + (n-1-layer) - i
    #print(i, j, 'layer', layer, 's', s, s+idx_in_layer)
    print(s+idx_in_layer)
0