jakaria_hossain

codeforces - special permutation

May 10th, 2020
904
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
  5. int main()
  6. {
  7.     ll t;
  8.     cin>>t;
  9.     while(t--)
  10.     {
  11.         ll n;
  12.         cin>>n;
  13.         if(n<4)cout<<"-1"<<endl;
  14.  
  15.         else
  16.         {
  17.             ll i;
  18.             if(n%2==1)i=n;
  19.             else i= n-1;
  20.             for(i;i>=1;i-=2)cout<<i<< " ";
  21.             cout<<"4 2 ";
  22.             for(i=6;i<=n;i+=2)cout<<i<< " ";
  23.             cout<<endl;
  24.         }
  25.     }
  26. }
RAW Paste Data