結果

問題 No.566 だいたい完全二分木
ユーザー tookunn_1213tookunn_1213
提出日時 2017-09-09 00:20:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 310 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-25 02:55:08
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

K = int(input())
s = 2**(K-2)
t = 2**(K)-1
ans = []
def dfs(a,b):
	stack = [(a,b)]
	while len(stack) > 0:
		d = stack.pop()
		if d[0] == d[1]:
			ans.append(d[0])
			continue
		m = (d[0] + d[1]) // 2
		stack.append((d[0],m))
		stack.append((m+1,d[1]))
dfs(1,s)
dfs(s+1,t)
print(' '.join([str(i) for i in ans]))
0