eolymp
bolt
Try our new interface for solving problems
Problems

Bracket sequences

Bracket sequences

Positive integer $n\:(1 \le n \le 10)$. is given. Print in alphabetical order all correct bracket sequences of length **2n**, assuming that the character '$($' comes before '$)$' in the alphabet. A correct bracket sequence is either an empty string, or a string like $(S)$, where $S$ is a correct bracket sequence, or a string like $S_1S_2$, where $S_1$ and $S_2$ are correct bracket sequences. \InputFile One integer $n\;(1 \le n \le 10)$. \OutputFile Print in alphabetical order all correct bracket sequences of length $2n$, one sequence per line, without spaces.
Time limit 1 second
Memory limit 128 MiB
Input example #1
3
Output example #1
((()))
(()())
(())()
()(())
()()()