#P3895. [湖南集训] Hungry Rabbit
[湖南集训] Hungry Rabbit
Description
A terrible flood struck unexpectedly in the summer, and the Rabbit Kingdom suffered an unprecedented famine. They have to go to the forest to look for food.
For simplicity, suppose there are rabbits in the kingdom, numbered to . During the days before relief arrives, exactly rabbits must go to the forest each day to gather food. Ferocious wolves live in the forest, but fortunately the rabbits have figured out the wolves’ hunting pattern: on each day, the wolves only hunt rabbits with certain indices. For safety, the rabbits sent out each day must all be ones that will not be hunted that day.
Because the rabbits going out differ from day to day, they define for each day a newcomer count : the number of rabbits that go out on day but did not go out on day . By convention, .
Now the rabbits want, under the safety requirement, that the newcomer count each day does not exceed . Please construct a valid plan.
Input Format
The first line contains four integers .
The next lines each contain a binary string of length . In the -th line, if the -th character is , then on day rabbit will be hunted; if it is , then rabbit will not be hunted on that day.
Output Format
Output lines. Each line should contain distinct integers between and , representing the indices of the rabbits that go out to gather food on that day.
If there is no valid plan, output a single line with -1.
5 4 3 1
1001
1101
1111
1110
0111
2 3 4
2 3 4
3 4 5
2 3 5
Hint
Sample 1 Explanation
For the sample, over the days, the sets of rabbits going out are respectively {2, 3, 4}; {2, 3, 4}; {3, 4, 5}; {2, 3, 5}.
Constraints
- For of the testdata, .
- For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号