結果

問題 No.392 2分木をたどれ
ユーザー ibot0709ibot0709
提出日時 2016-10-16 22:24:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 75,008 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 14:41:53
合計ジャッジ時間 1,358 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void solve(vector<string>& v, const int a) {
  if(a == 0) return;
  int n = 0;
  if (a % 2 == 0) {
    v.push_back("R");
    n = 0.5 * a - 1;
  } else {
    v.push_back("L");
    n = 0.5 * a;
  }
  solve(v, n);
}

int main () {

  int m;
  cin >> m;

  for (int i = 0; i < m; i++) {

    int a;
    cin >> a;

    vector<string> v;
    solve(v, a);
  
    reverse(v.begin(), v.end());

    for (string s : v) {
      cout << s;
    }
    cout << endl;
  }

  return 0;
}
0