# 2020 Multi-University Training Contest 5 解题报告

## 1003

``````#include <bits/stdc++.h>

using namespace std;

#define ll long long
ll input(){
ll x=0,f=0;char ch=getchar();
while(ch<‘0‘||ch>‘9‘) f|=ch==‘-‘,ch=getchar();
while(ch>=‘0‘&&ch<=‘9‘) x=x*10+ch-‘0‘,ch=getchar();
return f? -x:x;
}

const int N=3e5+7;

list<int> G[N];

int n,k;
int L,R;
void dfs(int l,int r){
if(r-l+1==n*2){
L=l,R=r;
return;
}
int mid=(l+r)>>1;
int p1=mid,p2=mid+1;

for(;p1>=l&&p2<=r;p1--,p2++){
while(!G[p1].empty()){
G[p2].push_front(G[p1].front());
G[p1].pop_front();
}
}

dfs(mid+1,r);
}

vector<int> Ans;

int main(){
int T=input();
while(T--){
n=input(),k=input();
int cnt=2*n*pow(2,k);
Ans.clear();

for(int i=1;i<=cnt;i++){
G[i].clear();
int a=input();
G[i].push_front(a);
}

dfs(1,cnt);

for(int i=L;i<=R;i++){
for (auto j=G[i].begin();j!=G[i].end();++j)
Ans.push_back(*j);
}

for(int i=0;i<Ans.size();i++){
printf("%d%c",Ans[i],i==Ans.size()-1? ‘\n‘:‘ ‘);
}
}
}
``````

2020 Multi-University Training Contest 5 解题报告

(0)
(0)