#P7269. [BalticOI 2005] Magic Parenthesis (Day1)
[BalticOI 2005] Magic Parenthesis (Day1)
Description
Given a string of length , consisting of (, ), and ].
There are ] in the whole string, and all other characters are left and right parentheses.
Now you are allowed to replace each ] with some number of ) characters. Find a way to obtain a valid parenthesis string after replacing all ] in .
Input Format
The first line contains two integers , representing the length of the string and the number of ].
The next several lines each contain at most characters, with a total of characters, representing the string .
Output Format
If there is no solution, output 0 and terminate the program.
If there is a solution, first output 1, then output lines. Each line contains one integer, representing how many ) characters the corresponding ] should be replaced with.
8 2
(((((])]
1
3
1
Hint
Sample Explanation
For sample , after performing the replacements as in the input, the resulting is ((((())))), which is a valid parenthesis string.
Constraints
For of the testdata, , , and .
This problem uses Special Judge.
Thanks to the SPJ provider
Notes
Translated from BalticOI 2005 Day1 B Magic Parenthesis.
Translated by ChatGPT 5
京公网安备 11011102002149号