結果

問題 No.392 2分木をたどれ
ユーザー kuisibakuisiba
提出日時 2016-10-06 17:10:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 65,308 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 01:01:46
合計ジャッジ時間 1,211 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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