結果
問題 |
No.566 だいたい完全二分木
|
ユーザー |
![]() |
提出日時 | 2020-04-12 15:19:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 457 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 58,880 KB |
最終ジャッジ日時 | 2024-09-22 02:38:27 |
合計ジャッジ時間 | 2,409 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 8 |
ソースコード
import math,sys K=int(input()) if K==2: ans=['1','3','2'] print(' '.join(ans)) sys.exit() v=2**(K-1)+1 P=[str(v)] left=[str(i) for i in range(1,v)] right=[str(i) for i in range(v+1,2**K)] tmp=K-1 while tmp!=0: if tmp==K-1 and K>=4: P+=left[2**(tmp-1):2**tmp+1] elif tmp==1: P+=['1'] else: P+=left[2**(tmp-1)-1:2**tmp] tmp-=1 right_root=right[len(right)//2] P.append(right_root) right.remove(right_root) P+=right print(' '.join(P))