結果
| 問題 |
No.392 2分木をたどれ
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-04-18 17:22:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,403 bytes |
| コンパイル時間 | 2,014 ms |
| コンパイル使用メモリ | 194,648 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-18 17:22:20 |
| 合計ジャッジ時間 | 2,709 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 |
ソースコード
/*
??????
??????
??????
??????
D P ????
??????
??????
??????
??????
??? l l?
??????
??????
?? OI ??
??????
*/
#include<bits/stdc++.h>
using namespace std;
//#define int long long
//#define eps 1e-9
//#define ENF 1e13
const int N=1e4;
const int mod=1e9+7;
inline int read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}
return x*f;
}
void write(int x)
{
if(x<0)putchar('-'),x=-x;
if(x<10)putchar(x+'0');
else write(x/10),putchar(x%10+'0');
}
int c[N];
int f[N];
int son[N][2];
void dfs(int u,int fa){
if(u>4094)return;
f[u]=fa;
son[u][0]=u*2+1;
son[u][1]=u*2+2;
dfs(son[u][0],u);
dfs(son[u][1],u);
}
signed main(){
// freopen("path.in","r",stdin);
// freopen("path.out","w",stdout);
dfs(0,0);
int m=read();
while(m--){
int a=read();
int now=a;
string s;
while(now!=0){
int nnow=f[now];
if(son[nnow][0]==now) s+="L";
else s+="R";
now=nnow;
}
reverse(s.begin(),s.end());
cout<<s<<"\n";
}
return 0;
}
// ?????????????AC????
// ?????????????????????????
// ??????????????????
// ????????????????????????????????????
// ???????????????????????????????
// ????????????
// ????????????
// ????????????
// ????????????????????
// ????????????????????
// ????????????????????????????????
// ???????????????????????
// ???????????
// ?????????????
vjudge1