Codeforces 1352 G. Special Permutation(构造)
作者:互联网
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#define IL inline
#define x first
#define y second
typedef long long ll;
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
if(n<=3)
cout<<-1<<endl;
else if(n==4)
{
cout<<"3 1 4 2"<<endl;
}
else
{
for(int i=1;i<=n;i+=2)
cout<<i<<' ';
if(n%2)
{
int pos=n;
pos-=3;
cout<<pos<<' ';
cout<<pos+2<<' ';
for(int i=pos-2;i>=2;i-=2)
cout<<i<<' ';
cout<<endl;
}
else
{
int pos=n-1;
pos-=3;
cout<<pos<<' ';
cout<<pos+4<<' ';
cout<<pos+2<<' ';
for(int i=pos-2;i>=1;i-=2)
cout<<i<<' ';
cout<<endl;
}
}
}
return 0;
}
模拟一遍就行了,我只是不会而已,蒟蒻。
标签:cout,int,1352,Codeforces,long,cin,include,Special,define 来源: https://blog.51cto.com/u_15287527/2987210