Problem-solving ideas: This condition is very loose, so as long as always find, find can not find so far stop, and then all match found 1 there is still left, then is not feasible. So that's a good thing to do with set.
#include <bits/stdc++.h> using namespace std;
typedef long Long LL;
const int MX = 2E5+10;
int N,M,Q,NUMBER[MX];
Char STR[MX];
Set <int> st[2];
Vector <int> VEC[MX];
int main () {scanf ("%s", str+1);
TOP1 = TOP2 = 0;
int Len = strlen (str+1), num,top;
for (int i=1;i<=len;i++) {num = str[i]-' 0 ';
St[num].insert (i);
} top = num = 0;
while (St[0].size ()) {Vec[top].push_back (*st[0].begin ());
St[0].erase (St[0].begin ());
int id = 1;
while (1) {Auto it = St[id].lower_bound (Vec[top].back ());
if (It==st[id].end ()) {if (!id) St[1].insert (Vec[top].back ()), Vec[top].erase (--vec[top].end ());
Break
} vec[top].push_back (*it);
St[id].erase (IT), id ^= 1;
} top++;
} if (St[1].size ()) return puts ("1");
printf ("%d\n", top); for (int i=0;i<top;i++) {printf ("%d", vec[I].size ());
for (int j=0;j<vec[i].size (); j + +) {printf ("%d", vec[i][j]);
} puts ("");
} return 0; }