結果

問題 No.566 だいたい完全二分木
ユーザー 👑 rin204rin204
提出日時 2022-01-19 23:26:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 455 ms
コンパイル使用メモリ 86,792 KB
実行使用メモリ 76,580 KB
最終ジャッジ日時 2023-08-15 08:14:09
合計ジャッジ時間 2,477 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,368 KB
testcase_01 AC 72 ms
71,304 KB
testcase_02 AC 72 ms
71,408 KB
testcase_03 AC 71 ms
71,380 KB
testcase_04 AC 74 ms
71,412 KB
testcase_05 AC 73 ms
71,284 KB
testcase_06 AC 74 ms
71,468 KB
testcase_07 AC 75 ms
71,460 KB
testcase_08 AC 78 ms
75,236 KB
testcase_09 AC 85 ms
76,304 KB
testcase_10 AC 86 ms
76,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

k = int(input())

ans = [i for i in range(1, k + 1)]
l = k + 1
r = (1 << k) - 1

lst = [(l, r)]
while lst:
    lst2 = []
    for l, r in lst:
        mid = (l + r) // 2
        ans.append(mid)
        if l != mid:
            lst2.append((l, mid - 1))
        if r != mid:
            lst2.append((mid + 1, r))
    
    lst = lst2

print(*ans)
0