PivotOJ

Palindromic Parentheses

시간 제한: 2000ms메모리 제한: 1024MB출처: ICPC Asia Jakarta Regional 2023BOJ 32087

문제

Construct a parentheses sequence consisting of NN characters such that it is balanced and the length of its longest palindromic subsequence (LPS) is exactly KK. Determine whether such a construction is possible. If there are several possible sequences, construct any of them.

A parentheses sequence consists of only character ( and ). A parentheses sequence is balanced if each character ( has a corresponding character ) and the pairs of parentheses are properly nested. For example, (), (()), (())(), and ((())()) are balanced. However, )(, ((), and ()) are not balanced.

A sequence is palindromic if it reads the same backwards as forwards. For example, ((, ), ())(, and (()(( are palindromic. However, (), )(, and (()) are not palindromic.

A subsequence can be derived from another sequence by removing zero or more characters without changing the order of the remaining characters. For example, (, ))), ())(, and (())() are subsequence of (())(). However, )(( and ((())) are not subsequence of (())().

The longest palindromic subsequence (LPS) of a sequence is a subsequence with the maximum number of characters, derived from that sequence and it is palindromic. For example, the LPS of sequence (())() is ())(, which can be obtained by removing the second and sixth characters. Therefore, the length of the LPS of (())() is 44.

입력

Input consists of two integers NN KK (2 ≤ N ≤ 2000; 1 ≤ K ≤ N). NN is an even number.

출력

If there is no such parentheses sequence such that it is balanced and the length of its LPS is exactly KK, then output -1.

Otherwise, output a string of NN characters, representing the parentheses sequence. If there are several possible answers, output any of them.

예제

예제 1

입력
6 4
출력
(())()

예제 2

입력
6 3
출력
(()())

예제 3

입력
4 1
출력
-1

예제 4

입력
14 11
출력
()((())()())()
코드를 제출하려면 로그인하세요.