CF1153C.Serval and Parenthesis Sequence

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.

In his favorite math class, the teacher taught him the following interesting definitions.

A parenthesis sequence is a string, containing only characters "(" and ")".

A correct parenthesis sequence is a parenthesis sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, parenthesis sequences "()()", "(())" are correct (the resulting expressions are: "(1+1)+(1+1)", "((1+1)+1)"), while ")(" and ")" are not. Note that the empty string is a correct parenthesis sequence by definition.

We define that s|s| as the length of string ss . A strict prefix s[1l]s[1\dots l] (1l<s)(1\leq l< |s|) of a string s=s1s2sss = s_1s_2\dots s_{|s|} is string s1s2sls_1s_2\dots s_l . Note that the empty string and the whole string are not strict prefixes of any string by the definition.

Having learned these definitions, he comes up with a new problem. He writes down a string ss containing only characters "(", ")" and "?". And what he is going to do, is to replace each of the "?" in ss independently by one of "(" and ")" to make all strict prefixes of the new sequence not a correct parenthesis sequence, while the new sequence should be a correct parenthesis sequence.

After all, he is just a primary school student so this problem is too hard for him to solve. As his best friend, can you help him to replace the question marks? If there are many solutions, any of them is acceptable.

输入格式

The first line contains a single integer s|s| ( 1s31051\leq |s|\leq 3 \cdot 10^5 ), the length of the string.

The second line contains a string ss , containing only "(", ")" and "?".

输出格式

A single line contains a string representing the answer.

If there are many solutions, any of them is acceptable.

If there is no answer, print a single line containing ":(" (without the quotes).

输入输出样例

  • 输入#1

    6
    (?????
    

    输出#1

    (()())
  • 输入#2

    10
    (???(???(?
    

    输出#2

    :(
    

说明/提示

It can be proved that there is no solution for the second sample, so print ":(".

首页