Bracket-and-bar Sequences

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Let us define the set of regular bracket-and-bar sequences RR recursively. It is the set of strings that can be obtained following only the rules below:

  • εR\varepsilon \in R (empty string)
  • A,BRABRA, B \in R \Rightarrow AB \in R (concatenation)
  • A,BRA, B \in R \Rightarrow (AA|BB)R \in R

For example, the sequences containing two triples "(|)" look as folows: "((|)|)", "(|(|))", "(|)(|)".

Establish a correspondence between regular bracket-and-bar sequences of certain length and integers, and implement that correspondence.