fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=998244353;
  5.  
  6. void solve() {
  7. int n,x;
  8. cin >> n >> x;
  9. vector<int> p(n);
  10. for(int i=0;i<x;i++){
  11. p[i]=i;
  12. }
  13. int cnt = x+1;
  14. for(int i=x;i<n-1;i++) {
  15. p[i]=cnt;
  16. cnt++;
  17. }
  18. if(x<n) p[n-1]=x;
  19. for(int i=0;i<n;i++) cout << p[i] << " ";
  20. cout << '\n';
  21. }
  22.  
  23. int main(){
  24. ios::sync_with_stdio(false);
  25. cin.tie(nullptr);
  26.  
  27. int t;
  28. cin >> t;
  29. while (t--) solve();
  30.  
  31.  
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5312KB
stdin
7
4 2
4 0
5 0
1 1
3 3
1 0
4 3
stdout
0 1 3 2 
1 2 3 0 
1 2 3 4 0 
0 
0 1 2 
0 
0 1 2 3