Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- ///****************
- //THE ALTERNATOR
- #define NMAX 23
- int n, k, st[NMAX];
- bitset<NMAX> bs;
- void doDaOps() {
- for (int i = 1; i <= k; i++)
- bs[st[i]] = true;
- cout << bs << endl;
- bs = 0;
- }
- void backTr(int k) {
- if (k - 1 == ::k) {
- doDaOps();
- return;
- }
- for (int i = st[k - 1] + 1; i <= n; i++) {
- st[k] = i;
- backTr(k + 1);
- }
- }
- int main() {
- cin >> n >> k;
- assert(n < NMAX - 2 && n >= k);
- backTr(1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement