General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
46738341 Practice:
Surprised_Pikachu
950C - 45 GNU C++11 Accepted 514 ms 7804 KB 2018-12-08 01:12:18 2018-12-08 01:12:18
 
 
→ Source
#include <bits/stdc++.h>
using namespace std;

void solve()
{
	string s;
	cin >> s;

	int z = 0;
	int az = 0;

	queue<int> curz;
	queue<int> curaz;

	vector<vector<int> > v;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == '0') 
		{
			if (az != 0)
			{
				az--;
				z++;

				v[curaz.front()].push_back(i + 1);

				curz.push(curaz.front());
				curaz.pop();
			}

			else
			{
				z++;
				vector<int> f;
				f.push_back(i + 1);
				v.push_back(f);
				curz.push(v.size() - 1);
			}
		}

		else
		{
			if (z == 0)
			{
				cout << -1 << endl;
				return;
			}

			else
			{
				z--;
				az++;

				v[curz.front()].push_back(i + 1);

				curaz.push(curz.front());
				curz.pop();
			}
		}
	}

	if (az != 0) 
	{
		cout << -1 << endl;
		return;
	}

	cout << v.size() << endl;

	for (int i = 0; i < v.size(); i++)
	{
		cout << v[i].size() << " ";

		for (int j = 0; j < v[i].size(); j++)
		{
			if (j) cout << " ";
			cout << v[i][j];
		}

		cout << endl; 
	}
}

int main()
{
	solve();
	return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details