Multiple Parentheses
Time limit2sMemory limit512 MB
Count ways to place a regular bracket sequence in each of N boxes so the total number of opening brackets is M and no box holds a sequence of length 2K, modulo 998244353.
- Level
Hard8 of 10
- Topics
- Combinatorics, Dynamic programming, Math, Number theory
- Solved
- No attempts yet
Problem
Consider strings consisting of the brackets '(' and ')'.
The regular bracket sequences are the strings which can be obtained by the following rules:
- The empty string is a regular bracket sequence.
- If is a regular bracket sequence, then
()is a regular bracket sequence. - If and are regular bracket sequences, then the concatenation of and is a regular bracket sequence.
You are given boxes numbered , and also two integers, and . Your task is to put exactly one regular bracket sequence in each of the boxes such that the following conditions are met:
- The total number of '
(' brackets in all boxes is equal to . - The regular bracket sequences of length cannot be put into the boxes.
Count the number of different ways to do that. Two distributions are considered different if there exists a number such that box contains different regular bracket sequences in those distributions.
Because the answer may be very large, print the answer modulo .
Input
The input contains one line with three integers , , and in it (, ).
Output
Print the answer modulo .
Hint
For the first example, the following distributions meet the conditions:
(()), empty;()(), empty;- empty,
(()); - empty,
()().
So, the answer is .