結果

問題 No.392 2分木をたどれ
ユーザー kuisiba
提出日時 2016-10-06 17:10:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 64,068 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 18:57:20
合計ジャッジ時間 887 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  int x, y;
  cin >> x;
  vector<int> v(x);

  for (auto& i : v) {
    cin >> i;
  }

  string s;

  for (size_t i = 0; i < v.size(); i++) {
    y = v.at(i);
    while (y > 0) {
      if (y & 1) {
        s.push_back('L');
        y = (y - 1) / 2;
      } else {
        s.push_back('R');
        y = (y - 2) / 2;
      }
    }
    reverse(begin(s), end(s));
    for (auto j : s) {
      cout << j;
    }
    cout << endl;
    s.clear();
  }
  return 0;
}
0