讲解:https://blog.csdn.net/qq_45458915/article/details/105682206
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=4e5+10;
int a[N];
int s[N];
void add(int l,int r,int c)
{
s[l]+=c;
s[r+1]-=c;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
for(int i=1;i<=n/2;i++)
{
add(2,k*2,2);
add(min(a[i],a[n-i+1])+1,max(a[i],a[n-i+1])+k,-1);
add(a[i]+a[n-i+1],a[i]+a[n-i+1],-1);
}
int minn=0x3f3f3f3f;
int sum=0;
for(int i=2;i<=k*2;i++)
{
sum+=s[i];
minn=min(minn,sum);
}
printf("%d\n",minn);
for(int i=1;i<=k*2+1;i++) s[i]=0;
}
}