Ankit_132

C

Jan 3rd, 2024
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int t;
  7.     cin>>t;
  8.    
  9.     while(t--)
  10.     {
  11.         int n, x;
  12.         cin>>n>>x;
  13.  
  14.         if(x>=n-1 && !(x==0 && n==1))
  15.         {
  16.            cout<<-1<<"\n";
  17.            continue;
  18.         }
  19.  
  20.         for(int i=n; i>x+1; i--)
  21.             cout<<i<<" ";
  22.  
  23.         for(int i=1; i<=x+1; i++)
  24.             cout<<i<<" ";
  25.         cout<<"\n";
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment