t1
这题数据范围不大,就直接暴力模拟,开两个临时数组,搞两个指针,直接套就好,具体看代码
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N1 = 2e4 + 10;
int b[N1];
void gai(int *c , int n)
{
vector<int>v1 , v2 , v;
for(int i=1; i<=n/2; i++)
v1.push_back(c[i]);
for(int i=n/2+1; i<=n; i++)
v2.push_back(c[i]);
int r1 = 0 , r2 = 0;
for(int i=1; i<=n; i++)
{
if(i & 1) v.push_back(v2[r2 ++]);
else v.push_back(v1[r1 ++]);
}
for(int i=1; i<=n; i++)
c[i] = v[i - 1];
}
signed main()
{
int n , m ;
cin >> n >> m ;
for(int i=1; i<=n; i++) cin >> b[i];
while(m --) gai(b , n);
for(int i=1; i<=n; i++) cout << b[i] << " ";
cout << '
';
return 0;
}