Loading Similar Posts
//PATH TO ELEMENT
#include <bits/stdc++.h>
using namespace std;
string finder(vector<int> &v, int n, int idx){
//have to find node n
if(idx>=v.size()){
return "";
}
string ans;
if(v[idx]==n){
return "";
}
if(v[idx] > n){
//left child
ans = 'L' + finder(v,n,2*idx+1);
}
else if(v[idx] < n){
ans = 'R' + finder(v,n,2*idx+2);
}
return ans;
}
int main()
{
int h;
cin>>h;
int sz = (1<<(h+1)) - 1;
vector<int> v(sz);
for(int i=0; i<sz; i++){
cin>>v[i];
}
int n;
cin>>n;
cout<<finder(v,n,0)<<endl;
return 0;
}