AcWing 3537. 树查找
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e3+10;
int t,n,m,k,l,r,op,x,y;
int f[N];
void solve(){
memset(f,-1,sizeof(f));
cin>>n;
for(int i = 1;i<=n;i++){
cin>>f[i];
}
cin>>k;
t = 1<<(k-1);
if(t>=N||f[t]==-1){
cout<<"EMPTY";
return;
}
for(int i = 0;i<t;i++){
if(f[i+t]==-1){
return ;
}else{
cout<<f[i+t]<<" ";
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}