結果

問題 No.392 2分木をたどれ
ユーザー kk
提出日時 2020-07-02 03:10:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 1,944 ms
コンパイル使用メモリ 200,124 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-12 14:06:48
合計ジャッジ時間 2,483 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 7 ms
4,348 KB
testcase_02 AC 7 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0