結果

問題 No.566 だいたい完全二分木
ユーザー htkbhtkb
提出日時 2017-09-09 00:18:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 427 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-25 02:54:21
合計ジャッジ時間 2,827 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())
n = 2**K
a = []
ap = a.append
ap(n//2+1)
queue = [(n//2, 2)]
qap = queue.append
pop = queue.pop
while queue:
    c, i = pop()
    left = c>>1
    right = c+(c>>1)
    if left+1 < n and left+1 not in a:
        ap(left+1)
    if right+1 < n and right+1 not in a:
        ap(right+1)
    if i < K:
        qap((right, i+1))
        qap((left, i+1))
    elif 1 not in a:
        ap(1)

print(" ".join(map(str,a)))
0