結果

問題 No.1034 テスターのふっぴーさん
ユーザー FromBooskaFromBooska
提出日時 2023-03-12 20:10:45
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 929 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 81,900 KB
実行使用メモリ 63,748 KB
最終ジャッジ日時 2023-10-18 10:46:10
合計ジャッジ時間 5,307 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,512 KB
testcase_01 AC 40 ms
53,512 KB
testcase_02 AC 40 ms
53,512 KB
testcase_03 AC 39 ms
53,512 KB
testcase_04 AC 38 ms
53,512 KB
testcase_05 AC 38 ms
53,512 KB
testcase_06 AC 39 ms
53,512 KB
testcase_07 AC 38 ms
53,512 KB
testcase_08 AC 38 ms
53,512 KB
testcase_09 AC 38 ms
53,512 KB
testcase_10 AC 38 ms
53,512 KB
testcase_11 AC 38 ms
53,512 KB
testcase_12 AC 38 ms
53,512 KB
testcase_13 AC 40 ms
53,512 KB
testcase_14 AC 39 ms
53,512 KB
testcase_15 AC 39 ms
53,512 KB
testcase_16 AC 39 ms
53,512 KB
testcase_17 AC 39 ms
53,512 KB
testcase_18 AC 42 ms
59,388 KB
testcase_19 AC 39 ms
53,512 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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 = 0
    for l in range(layer):
        s += (n-l*2-1)*4
    #print('layer', layer, 's', s)
    # その中の何番目か、第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