Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- using namespace std;
- int cnt[2], s[30], a, b;
- int main() {
- freopen("input.txt", "r", stdin);
- cin >> a >> b;
- int top_mask = 1;
- for (int i = 0; i < a + b; i++)
- top_mask *= 2;
- for (int i = 0; i < top_mask; i++) {
- cnt[0] = cnt[1] = 0;
- for (int j = 0, k = 1; j < a + b; j++, k *= 2) {
- s[j] = ((k & i) != 0);
- cnt[ s[j] ]++;
- }
- if (cnt[0] == b && cnt[1] == a) {
- bool ok = true;
- int l = a + b;
- for (int j = 1; j < l; j++) {
- if (s[j] + s[j - 1] == 0) {
- ok = false;
- break;
- }
- }
- for (int j = 1; j < l - 1; j++) {
- if (s[j] == 1 && s[j - 1] + s[j + 1] == 0) {
- ok = false;
- break;
- }
- }
- if ((s[0] == 1 && s[1] == 0) || (s[l - 1] == 1 && s[l - 2] == 0))
- ok = false;
- if (ok) {
- for (int j = 0; j < l; j++)
- cout << s[j];
- cout << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement