結果

問題 No.392 2分木をたどれ
ユーザー imulanimulan
提出日時 2016-07-13 02:26:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 163,352 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 16:21:56
合計ジャッジ時間 1,994 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    int m;
    cin >>m;
    rep(M,m)
    {
        int a;
        cin >>a;

        int now=a;
        string ans="";

        while(now>0)
        {
            int nx=(now-1)/2;
            if(2*nx+1==now) ans+="L";
            else if(2*nx+2==now) ans+="R";
            else printf("error!\n");

            now=nx;
        }

        reverse(all(ans));
        cout << ans << endl;
    }
    return 0;
}
0