Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n;
- string s;
- vector<vector<int>> ans;
- int main()
- {
- cin >> n >> s;
- for(int i = n; i >= 1; --i)
- {
- int switches = 0;
- vector<bool> switched(n, false);
- vector<int> h;
- for(int j = 0; j < n && switches < i; ++j)
- if (s[j] == '1')
- {
- switched[j] = true;
- switches++;
- h.push_back(j);
- }
- if (switches < i)
- {
- for (int j = 0; j < n && switches < i; ++j)
- if (switched[j] == false)
- {
- switches++;
- h.push_back(j);
- }
- }
- assert(switches == i);
- sort(h.begin(), h.end());
- ans.push_back(h);
- for(auto j: h)
- s[j] ^= 1;
- }
- bool ok = 1;
- for(auto i: s) ok &= i == '0';
- if (!ok)
- {
- cout << "No" << endl;
- return 0;
- }
- cout << "Yes" << endl;
- reverse(ans.begin(), ans.end());
- for(auto i: ans)
- {
- for(auto j: i) cout << j + 1 << ' ';
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement