結果
問題 | No.392 2分木をたどれ |
ユーザー |
|
提出日時 | 2020-07-02 03:10:04 |
言語 | C++17 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 463 bytes |
コンパイル時間 | 2,162 ms |
使用メモリ | 9,708 KB |
最終ジャッジ日時 | 2023-02-27 00:47:32 |
合計ジャッジ時間 | 2,489 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,720 KB |
testcase_01 | AC | 7 ms
9,708 KB |
testcase_02 | AC | 7 ms
7,568 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) string ans[4096]; void dfs(int x, int p) { if (x >= 4096) return; if (p != -1) ans[x] = x % 2 ? ans[p] + "L" : ans[p] + "R"; dfs(2*x+1, x); dfs(2*x+2, x); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); dfs(0, -1); int n; cin >> n; REP (i, n) { int x; cin >> x; cout << ans[x] << endl; } return 0; }