Brackets
Hard
Execution time limit is 2 seconds
Runtime memory usage limit is 64 megabytes
Consider all valid bracket sequences of length (2N). These sequences are arranged in lexicographical order, where an opening bracket is considered smaller than a closing bracket. Each sequence is numbered starting from (1).
Your task is to determine the (K)-th sequence in this order.
Input
The first line contains the integer (N) ((1 N 100)), and the second line contains a natural number (K) ((1 K 10^1000+255)), which indicates the sequence number you need to find.
Output
Output a single line containing the (K)-th valid bracket sequence of length (2N). The output should not include any spaces. If there are fewer than (K) sequences of length (2N), print "No solution for this testcase." (without quotes).
Examples
Input #1
Answer #1
Submissions 35
Acceptance rate 14%