Brackets
시간 제한1초메모리 제한512 MB
길이 2n인 수열에서 1부터 n까지의 각 수가 정확히 두 번 나타난다. 같은 수의 두 위치에 같은 괄호를 넣어 올바른 괄호열을 만들되, 사전순으로 가장 작은 것을 구한다.
문제
There are elements divided into pairs.
For each pair, you should either assign an opening bracket to both elements, or closing bracket to both elements. You need to make the resulting sequence of brackets a correct bracket sequence or determine that it is impossible. If there are several possible solutions, find the solution with the smallest lexicographically string (of brackets, '(' is smaller than ')').
입력
The first line contains one integer ().
The next line contains integers, (). All integers from to appear exactly two times in this sequence.
출력
If it is impossible to choose one type of bracket for each pair to make the derived bracket sequence correct, print "(" (Russian sad smiley). Otherwise, print the desired lexicographically minimal correct bracket sequence.