結果

問題 No.566 だいたい完全二分木
ユーザー nisizawanisizawa
提出日時 2017-12-03 04:27:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 10,660 KB
実行使用メモリ 8,360 KB
最終ジャッジ日時 2023-08-18 22:31:01
合計ジャッジ時間 1,430 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,812 KB
testcase_01 AC 16 ms
7,892 KB
testcase_02 AC 15 ms
7,848 KB
testcase_03 AC 16 ms
7,880 KB
testcase_04 AC 16 ms
7,804 KB
testcase_05 AC 16 ms
7,744 KB
testcase_06 AC 16 ms
7,852 KB
testcase_07 AC 16 ms
7,748 KB
testcase_08 AC 17 ms
7,820 KB
testcase_09 AC 17 ms
8,324 KB
testcase_10 AC 19 ms
8,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
        
def print_ans(ls):
    c = len(ls) // 2
    val = ls[c]
    
    if val == 2:
        sys.stdout.write('3 2 1 ')    
    elif val != 1 and val != 3:
        sys.stdout.write(str(val) + ' ')
    
    if len(ls) >= 2:
       print_ans(ls[:c])
    if len(ls) >= 3:
        print_ans(ls[c + 1:])
    
k = int(input())

ls = list(range(1, 2**k))
print_ans(ls)
print('')
0