Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- vector<int> a;
- vector<bool> flag;
- int n, t;
- void rec(int v){
- if(t == 0){
- return;
- }
- if(v == n){
- for(int i = 0; i < a.size(); ++i){
- cout << a[i] + 1 << " ";
- }
- cout << endl;
- --t;
- }
- for(int i = 0; i < n; ++i){
- if(i != v && !flag[i]){
- flag[i] = true;
- a.push_back(i);
- rec(v + 1);
- flag[i] = false;
- a.pop_back();
- }
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- cin >> n >> t;
- flag.resize(n, false);
- rec(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement