English · Original
Chinese · Translation
Formal · Original
Japate, while traveling through the forest of Mala, saw _N_ bags of gold lying in a row. Each bag has some **distinct** weight of gold between 1 to _N_. Japate can carry only one bag of gold with him, so he uses the following strategy to choose a bag.
Initially, he starts with an empty bag (zero weight). He considers the bags in some order. If the current bag has a higher weight than the bag in his hand, he picks the current bag.
Japate put the bags in some order. Japate realizes that he will pick _A_ bags, if he starts picking bags from the front, and will pick _B_ bags, if he starts picking bags from the back. By picking we mean replacing the bag in his hand with the current one.
Now he wonders how many permutations of bags are possible, in which he picks _A_ bags from the front and _B_ bags from back using the above strategy.
Since the answer can be very large, output it modulo 998244353.
## Input
The only line of input contains three space separated integers _N_ (1 ≤ _N_ ≤ 105), _A_ and _B_ (0 ≤ _A_, _B_ ≤ _N_).
## Output
Output a single integer — the number of valid permutations modulo 998244353.
[samples]
## Note
In sample case 1, the only possible permutation is \[1\]
In sample cases 2 and 3, only two permutations of size 2 are possible:{\[1, 2\], \[2, 1\]}. The values of _a_ and _b_ for first permutation is 2 and 1, and for the second permutation these values are 1 and 2.
In sample case 4, out of 120 permutations of \[1, 2, 3, 4, 5\] possible, only 22 satisfy the given constraints of _a_ and _b_.
Japate 在 Mala 森林中旅行时,看到一排 #cf_span[N] 个装有黄金的袋子。每个袋子的黄金重量互不相同,且在 #cf_span[1] 到 #cf_span[N] 之间。Japate 只能携带一个袋子,因此他采用以下策略选择袋子:
最初,他手中拿着一个空袋(重量为 0)。他按某种顺序考虑这些袋子。如果当前袋子的重量大于他手中袋子的重量,他就拿起当前的袋子。
Japate 将袋子排成某种顺序。他发现,如果从前往后开始挑选,他会捡起 #cf_span[A] 个袋子;如果从后往前开始挑选,他会捡起 #cf_span[B] 个袋子。这里的“捡起”指的是用当前袋子替换手中原来的袋子。
现在他想知道,有多少种袋子的排列方式,使得他按照上述策略从前往后捡起 #cf_span[A] 个袋子,从后往前捡起 #cf_span[B] 个袋子。
由于答案可能很大,请输出对 #cf_span[998244353] 取模的结果。
输入仅一行,包含三个用空格分隔的整数 #cf_span[N](#cf_span[1 ≤ N ≤ 105])、#cf_span[A] 和 #cf_span[B](#cf_span[0 ≤ A, B ≤ N])。
输出一个整数——满足条件的排列数,对 #cf_span[998244353] 取模。
在样例 #cf_span[1] 中,唯一可能的排列是 #cf_span[[1]]。
在样例 #cf_span[2] 和 #cf_span[3] 中,大小为 #cf_span[2] 的排列只有两种可能:#cf_span[{[1, 2], [2, 1]}]。对于第一个排列,#cf_span[a] 和 #cf_span[b] 的值分别为 #cf_span[2] 和 #cf_span[1];对于第二个排列,这两个值分别为 #cf_span[1] 和 #cf_span[2]。
在样例 #cf_span[4] 中,在 #cf_span[[1, 2, 3, 4, 5]] 的 120 种排列中,只有 22 种满足给定的 #cf_span[a] 和 #cf_span[b] 约束。
## Input
输入仅一行,包含三个用空格分隔的整数 #cf_span[N](#cf_span[1 ≤ N ≤ 105])、#cf_span[A] 和 #cf_span[B](#cf_span[0 ≤ A, B ≤ N])。
## Output
输出一个整数——满足条件的排列数,对 #cf_span[998244353] 取模。
[samples]
## Note
在样例 #cf_span[1] 中,唯一可能的排列是 #cf_span[[1]]。在样例 #cf_span[2] 和 #cf_span[3] 中,大小为 #cf_span[2] 的排列只有两种可能:#cf_span[{[1, 2], [2, 1]}]。对于第一个排列,#cf_span[a] 和 #cf_span[b] 的值分别为 #cf_span[2] 和 #cf_span[1];对于第二个排列,这两个值分别为 #cf_span[1] 和 #cf_span[2]。在样例 #cf_span[4] 中,在 #cf_span[[1, 2, 3, 4, 5]] 的 120 种排列中,只有 22 种满足给定的 #cf_span[a] 和 #cf_span[b] 约束。
**Definitions**
Let $ N \in \mathbb{Z}^+ $, $ A, B \in \mathbb{Z} $ with $ 0 \leq A, B \leq N $.
Let $ S_N $ be the set of all permutations of $ \{1, 2, \dots, N\} $.
For a permutation $ \pi \in S_N $, define:
- $ f(\pi) $: number of *left-to-right maxima* in $ \pi $, i.e., elements $ \pi_i $ such that $ \pi_i > \pi_j $ for all $ j < i $ (with $ \pi_1 $ always counted).
- $ g(\pi) $: number of *right-to-left maxima* in $ \pi $, i.e., elements $ \pi_i $ such that $ \pi_i > \pi_j $ for all $ j > i $ (with $ \pi_N $ always counted).
**Constraints**
1. $ 1 \leq N \leq 10^5 $
2. $ 0 \leq A, B \leq N $
**Objective**
Compute the number of permutations $ \pi \in S_N $ such that:
$$
f(\pi) = A \quad \text{and} \quad g(\pi) = B
$$
modulo $ 998244353 $.
API Response (JSON)
{
"problem": {
"name": "G. Bandit Blues",
"description": {
"content": "Japate, while traveling through the forest of Mala, saw _N_ bags of gold lying in a row. Each bag has some **distinct** weight of gold between 1 to _N_. Japate can carry only one bag of gold with him,",
"description_type": "Markdown"
},
"platform": "Codeforces",
"limit": {
"time_limit": 3000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "CF960G"
},
"statements": [
{
"statement_type": "Markdown",
"content": "Japate, while traveling through the forest of Mala, saw _N_ bags of gold lying in a row. Each bag has some **distinct** weight of gold between 1 to _N_. Japate can carry only one bag of gold with him,...",
"is_translate": false,
"language": "English"
},
{
"statement_type": "Markdown",
"content": "Japate 在 Mala 森林中旅行时,看到一排 #cf_span[N] 个装有黄金的袋子。每个袋子的黄金重量互不相同,且在 #cf_span[1] 到 #cf_span[N] 之间。Japate 只能携带一个袋子,因此他采用以下策略选择袋子:\n\n最初,他手中拿着一个空袋(重量为 0)。他按某种顺序考虑这些袋子。如果当前袋子的重量大于他手中袋子的重量,他就拿起当前的袋子。\n\nJapate 将袋子...",
"is_translate": true,
"language": "Chinese"
},
{
"statement_type": "Markdown",
"content": "**Definitions** \nLet $ N \\in \\mathbb{Z}^+ $, $ A, B \\in \\mathbb{Z} $ with $ 0 \\leq A, B \\leq N $. \nLet $ S_N $ be the set of all permutations of $ \\{1, 2, \\dots, N\\} $. \nFor a permutation $ \\pi \\in...",
"is_translate": false,
"language": "Formal"
}
]
}