302555: CF494A. Treasure

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:4 Solved:0

Description

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 $ 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 $ ( $ 1<=i<=|s| $ ) there are no more ')' characters than '(' characters among the first $ i $ characters of $ 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 $ 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 $ ( $ 1<=i<=|s| $ ) there are no more ')' characters than '(' characters among the first $ i $ characters of $ 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 $ 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 $ ( $ 1<=i<=|s| $ ) there are no more ')' characters than '(' characters among the first $ i $ characters of $ 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
2

输入样例 #2

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

输出样例 #2

2
2
1

输入样例 #3

#

输出样例 #3

-1

输入样例 #4

(#)

输出样例 #4

-1

说明

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

Input

题意翻译

得你一个包含"("和"#"的序列,'#'需要转换为k个右括号 ( k > 0 ),那么这个表达式的括号能否在你转化后匹配,如果可以,输出每一个'#'转化的右括号数 k 的值;如果不能,就输出 −1 可能有很多组满足的情况只需输出一组即可 ~~Special Judge 万岁~~

加入题单

上一题 下一题 算法标签: