fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. int t;
  9. cin>>t;
  10. while(t--)
  11. {
  12. int n,k;
  13. vector<int> a;
  14. cin>>n>>k;
  15. for (int i=1;i<=n;i++)
  16. a.push_back(i);
  17.  
  18. if (k<=floor(n/2))
  19. {
  20. vector<int> b(a.begin(),a.begin()+n-k),c(a.begin()+n-k,a.end());
  21. for (int i=1;i<=k;i++)
  22. {
  23. b.insert(b.begin()+i,c[i-1]);
  24. }
  25. for(int i=0;i<n;i++)
  26. {
  27. cout<<b[i]<<' ';
  28. }
  29. cout<<endl;
  30. }
  31. else
  32. {
  33. cout<<-1<<endl;
  34. }
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 5592KB
stdin
5
1 0
5 2
6 6
2 1
6 1
stdout
1 
1 4 5 2 3 
-1
1 2 
1 6 2 3 4 5