#P494A. Treasure

Treasure

Treasure

题面翻译

得你一个包含"("和"#"的序列,'#'需要转换为k个右括号 ( k > 0 ),那么这个表达式的括号能否在你转化后匹配,如果可以,输出每一个'#'转化的右括号数 k 的值;如果不能,就输出 −1

可能有很多组满足的情况只需输出一组即可 Special Judge 万岁

题目描述

Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that the goal is to replace each '#' with one or more ')' characters so that the final string becomes beautiful.

Below there was also written that a string is called beautiful if for each i i ( 1<=i<=s 1<=i<=|s| ) there are no more ')' characters than '(' characters among the first i i characters of s s and also the total number of '(' characters is equal to the total number of ')' characters.

Help Malek open the door by telling him for each '#' character how many ')' characters he must replace it with.

输入格式

Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that the goal is to replace each '#' with one or more ')' characters so that the final string becomes beautiful.

Below there was also written that a string is called beautiful if for each i i ( 1<=i<=s 1<=i<=|s| ) there are no more ')' characters than '(' characters among the first i i characters of s s and also the total number of '(' characters is equal to the total number of ')' characters.

Help Malek open the door by telling him for each '#' character how many ')' characters he must replace it with.

输出格式

Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that the goal is to replace each '#' with one or more ')' characters so that the final string becomes beautiful.

Below there was also written that a string is called beautiful if for each i i ( 1<=i<=s 1<=i<=|s| ) there are no more ')' characters than '(' characters among the first i i characters of s s and also the total number of '(' characters is equal to the total number of ')' characters.

Help Malek open the door by telling him for each '#' character how many ')' characters he must replace it with.

样例 #1

样例输入 #1

(((#)((#)

样例输出 #1

1
2

样例 #2

样例输入 #2

()((#((#(#()

样例输出 #2

2
2
1

样例 #3

样例输入 #3

#

样例输出 #3

-1

样例 #4

样例输入 #4

(#)

样例输出 #4

-1

提示

s |s| denotes the length of the string s s .