結果

問題 No.566 だいたい完全二分木
ユーザー sho_00sho_00
提出日時 2020-04-12 15:28:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 419 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 81,716 KB
実行使用メモリ 59,688 KB
最終ジャッジ日時 2023-10-22 01:17:46
合計ジャッジ時間 1,921 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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==1:
    P+=['1']
  else:
    P+=left[2**(tmp-1)-1:2**tmp-1]
  tmp-=1
right_root=right[len(right)//2]
P.append(str(v-1))
P.append(right_root)
right.remove(right_root)
P+=right
print(' '.join(P))
0