fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define nl "\n"
  5. #define OO 0x3f3f3f3f
  6. using namespace std;
  7.  
  8. void ta2to2a()
  9. {
  10. ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr);
  11. #ifndef ONLINE_JUDGE
  12. freopen("input.txt", "r", stdin);
  13. freopen("output.txt", "w", stdout);
  14. #endif
  15. }
  16. int n, m;
  17. vector<ll> v;
  18. void sequence(int start)
  19. {
  20. v.push_back(start);
  21. if (v.size() == n)
  22. {
  23. for (auto it : v)
  24. {
  25. cout << it << " ";
  26. }
  27. cout << nl;
  28. return;
  29. }
  30. for (int i = start; i < m; i++)
  31. {
  32. sequence(i + 1);
  33. v.pop_back();
  34. }
  35. }
  36. void solve()
  37. {
  38. cin >> n >> m;
  39. for (int i = 1; i <= n; i++)
  40. {
  41. sequence(i);
  42. v.clear();
  43. }
  44. }
  45. int main()
  46. {
  47. ta2to2a();
  48. int t = 1;
  49. // cin >> t;
  50. while (t--)
  51. {
  52. solve();
  53. }
  54. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty