結果

問題 No.566 だいたい完全二分木
ユーザー htkb
提出日時 2017-09-09 00:18:10
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 427 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-07 12:32:24
合計ジャッジ時間 2,740 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 10
権限があれば一括ダウンロードができます

ソースコード

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