結果
問題 | No.392 2分木をたどれ |
ユーザー |
![]() |
提出日時 | 2019-08-03 12:39:21 |
言語 | Python3 (3.10.1 + numpy 1.22.3 + scipy 1.8.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 584 bytes |
コンパイル時間 | 62 ms |
使用メモリ | 8,420 KB |
最終ジャッジ日時 | 2023-02-07 21:49:26 |
合計ジャッジ時間 | 919 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
8,412 KB |
testcase_01 | AC | 39 ms
8,400 KB |
testcase_02 | AC | 39 ms
8,420 KB |
ソースコード
from collections import deque def bfs(start): queue = deque([]) queue.append(start) route = [-1] * 4095 route[0] = '' while len(queue) > 0: current_node = queue.popleft() if 2047 <= current_node <= 4094: continue route[2*current_node+1] = route[current_node] + 'L' route[2*current_node+2] = route[current_node] + 'R' queue.append(2*current_node+1) queue.append(2*current_node+2) return route route = bfs(0) m = int(input()) for _ in range(m): A_i = int(input()) print(route[A_i])