Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated, T-shirts + prizes!)
B
Kuroni and Simple Strings
Codeforces
1200
原题
← AC →
翻译中…

Now that Kuroni has reached 10 years old, he is a big boy and doesn't like arrays of integers as presents anymore. This year he wants a Bracket sequence as a Birthday present. More specifically, he wants a bracket sequence so complex that no matter how hard he tries, he will not be able to remove a simple subsequence!

翻译中…

We say that a string formed by $n$ characters '(' or ')' is simple if its length $n$ is even and positive, its first $\frac{n}{2}$ characters are '(', and its last $\frac{n}{2}$ characters are ')'. For example, the strings () and (()) are simple, while the strings )( and ()() are not simple.

翻译中…

Kuroni will be given a string formed by characters '(' and ')' (the given string is not necessarily simple). An operation consists of choosing a subsequence of the characters of the string that forms a simple string and removing all the characters of this subsequence from the string. Note that this subsequence doesn't have to be continuous. For example, he can apply the operation to the string ')()(()))', to choose a subsequence of bold characters, as it forms a simple string '(())', delete these bold characters from the string and to get '))()'.

翻译中…

Kuroni has to perform the minimum possible number of operations on the string, in such a way that no more operations can be performed on the remaining string. The resulting string does not have to be empty.

翻译中…

Since the given string is too large, Kuroni is unable to figure out how to minimize the number of operations. Can you help him do it instead?

翻译中…

A sequence of characters $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly, zero or all) characters.

翻译中…

Input

翻译中…

The only line of input contains a string $s$ ($1 \le |s| \le 1000$) formed by characters '(' and ')', where $|s|$ is the length of $s$.

翻译中…

Output

翻译中…

In the first line, print an integer $k$  — the minimum number of operations you have to apply. Then, print $2k$ lines describing the operations in the following format:

翻译中…

For each operation, print a line containing an integer $m$  — the number of characters in the subsequence you will remove.

翻译中…

Then, print a line containing $m$ integers $1 \le a_1 \lt a_2 \lt \dots \lt a_m$  — the indices of the characters you will remove. All integers must be less than or equal to the length of the current string, and the corresponding subsequence must form a simple string.

翻译中…

If there are multiple valid sequences of operations with the smallest $k$, you may print any of them.

翻译中…

Note

翻译中…

In the first sample, the string is '(()(('. The operation described corresponds to deleting the bolded subsequence. The resulting string is '(((', and no more operations can be performed on it. Another valid answer is choosing indices $2$ and $3$, which results in the same final string.

翻译中…

In the second sample, it is already impossible to perform any operations.

翻译中…

样例

Input #1
(()((
Output #1
1
2
1 3
InputCopy OutputCopy
Input #2
)(
Output #2
0
InputCopy OutputCopy
Input #3
(()())
Output #3
1
4
1 2 5 6
InputCopy OutputCopy
题目信息
题号
1305B
时间限制
1 s
内存限制
256 MB
标签
构造
贪心
字符串
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。