fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define endl '\n'
  6. #define dtype long long
  7. #define mod 1000000007
  8. #define case(t, c) cout<<"Case #"<<t<<":"<<c
  9. #define least_one_pos(x) __builtin_ffs(x)
  10. #define leading_zeros(x) __builtin_clz(x)
  11. #define tailing_zeros(x) __builtin_ctz(x)
  12. #define num_of_one(x) __builtin_popcount(x)
  13. #define msb(x) 32-leading_zeros(x)
  14.  
  15. int main() {
  16. ios_base::sync_with_stdio(false), cin.tie(nullptr);
  17. int n;
  18. cin>>n;
  19. n*=2;
  20. vector<int>vc(n);
  21. iota(vc.begin(),vc.end(),1);
  22. for (int i = 0; i < (1ll<<n); ++i) {
  23. if(num_of_one(i)==3)
  24. {
  25. vector<int>aa,bb;
  26. for (int j = 0; j < n; ++j) {
  27. if(i&(1<<j))
  28. aa.emplace_back(vc[j]);
  29. else
  30. bb.emplace_back(vc[j]);
  31. }
  32. sort(aa.begin(),aa.end());
  33. sort(bb.rbegin(),bb.rend());
  34. for (auto &j : aa) {
  35. cout<<j<<" ";
  36. }
  37. cout<<endl;
  38. for (auto &j : bb) {
  39. cout<<j<<" ";
  40. }
  41. cout<<endl;
  42.  
  43. }
  44. }
  45.  
  46. return 0;
  47. }
  48.  
  49.  
Success #stdin #stdout 0.01s 5384KB
stdin
3
stdout
1 2 3 
6 5 4 
1 2 4 
6 5 3 
1 3 4 
6 5 2 
2 3 4 
6 5 1 
1 2 5 
6 4 3 
1 3 5 
6 4 2 
2 3 5 
6 4 1 
1 4 5 
6 3 2 
2 4 5 
6 3 1 
3 4 5 
6 2 1 
1 2 6 
5 4 3 
1 3 6 
5 4 2 
2 3 6 
5 4 1 
1 4 6 
5 3 2 
2 4 6 
5 3 1 
3 4 6 
5 2 1 
1 5 6 
4 3 2 
2 5 6 
4 3 1 
3 5 6 
4 2 1 
4 5 6 
3 2 1