Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const short LOVE = 1411;
- int n, l, s;
- int cnt;
- int main(){
- //freopen("Test.INP", "r", stdin);
- //freopen("Test.OUT", "w", stdout);
- cin.tie(NULL)->sync_with_stdio(false);
- cin >> l >> n;
- vector<pair<int, int>> a(n);
- for (int i = 0; i < n; ++i)
- cin >> a[i].second,
- s += a[i].second,
- a[i].first = i + 1;
- while (s++ < l)
- a.push_back({0, 1});
- sort(a.begin(), a.end());
- for (pair<int, int> &i : a)
- if (i.first != 0) {
- swap(i, a.front());
- break;
- }
- do {
- for (pair<int, int> i : a)
- for (int j = 0; j < i.second; ++j)
- cout << i.first << ' ';
- cout << '\n';
- } while (++cnt < 1000 && next_permutation(a.begin(), a.end()));
- return 0;
- }
Add Comment
Please, Sign In to add comment