QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 256 MB 총점: 100

#18655. Dispersed parentheses

통계

算术表达式中的计算顺序通常由某种括号排列来确定。例如,$(3 \cdot (2 + 1)) \cdot (4 - 5)$。在删除表达式中除括号外的所有元素后,剩余的符号形成一个括号序列 $(())()$。我们假设添加字符 0 不会破坏该序列。我们称这样的序列为分散括号序列。它也可以被定义如下:

  • 空字符串是一个分散括号序列。
  • 如果 $S$ 和 $T$ 是分散括号序列,那么字符串 $0S$、$S0$、$(S)$ 和 $ST$ 也是分散括号序列。

一个分散括号序列的深度是该序列的所有前缀中,左括号与右括号数量之差的最大值。(字符串 $S$ 的前缀是通过从 $S$ 的末尾删除若干字符而得到的字符串。例如,字符串 ABCAB 的前缀是 ""AABABCABCAABCAB)。因此,序列 (0)(0())0 的深度等于 $2$(其前缀 (0)(0( 包含三个左括号和一个右括号,差值为 $2$)。

计算长度为 $n$ 且深度为 $k$ 的可能的分散括号序列的数量。

输入格式

单行包含空格分隔的两个整数 $n$ 和 $k$($1 \le n \le 300$,$0 \le k \le n$)。

输出格式

输出长度为 $n$ 且深度为 $k$ 的可能的分散括号序列的数量模 $10^9 + 9$ 的结果。

样例

输入样例 1

3 0

输出样例 1

1

输入样例 2

3 1

输出样例 2

3

输入样例 3

3 2

输出样例 3

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.