#P15612. [ICPC 2021 Jakarta R] Feeder Robot

[ICPC 2021 Jakarta R] Feeder Robot

题目描述

Vincent switches his retirement plan from raising horses and goats into raising chickens. He procures NN chickens and lays each of them into their own coop (hen house). The coops are placed on a single line numbered sequentially from 11 at the left-most to NN at the right-most.

To make his retirement blissful (or at least he thought), Vincent buys a feeder robot. This feeder robot is to be loaded with MM pellets and it will distribute them for the chickens to feed on. The feeder robot will move from one coop to an adjacent coop and distribute 11 pellet to each coop it visits. If a coop is visited xx times by the robot including the robot's initial position, then it will get xx pellets.

However, Vincent has just noticed that he cannot control how the robot moves. Let the robot be in front of coop pp. If the robot still has pellets to distribute, it will move to an adjacent coop (coop p1p - 1 or p+1p + 1) at random and distributes 11 pellet to that coop. This process repeats until the robot has no more pellets to distribute. Note that if p=1p = 1, then the robot will move to coop 22; similarly, if p=Np = N, then the robot will move to coop N1N - 1.

Since Vincent dislikes you even though you are his only friend, he challenges you to a problem. The challenge is to count how many possible pellets distributions are there if the robot starts at coop AA. A pellets distribution is defined as a tuple R,S1..N\langle R, S_{1..N}\rangle where RR is the final position of the robot and SiS_{i} is the number of pellets coop ii gets. Two distributions are different if and only if the final position of the robot differs or there is a coop that gets a different number of pellets. The robot's movement or the order when the coop gets a pellet does not matter.

Since the output can be quite big, Vincent requires you to give him the non-negative remainder when the output is divided by 998244353998 244 353. Believing that you cannot solve it, Vincent agrees to award you with a hefty reward if you managed to solve his challenge.

For example, let N=4N = 4, M=3M = 3, and A=2A = 2. In this example, there are 33 different pellets distributions.

  • 2,{1,2,0,0}\langle 2, \{1, 2, 0, 0\}\rangle: The robot ends at coop 22 and the number of pellets each coop gets is {1,2,0,0}\{1, 2, 0, 0\}. The robot's movement that causes this distribution is: The robot starts at coop 22 and distributes 11 pellet to coop 22; it moves to coop 11 and distributes 11 pellet to coop 11; it moves to coop 22 and distributes 11 pellet to coop 22. In a simple notation, the robot's movement is 2122 \rightarrow 1 \rightarrow 2
  • 2,{0,2,1,0}\langle 2, \{0, 2, 1, 0\}\rangle: The robot ends at coop 22 and the number of pellets each coop gets is {0,2,1,0}\{0, 2, 1, 0\}. The robot's movement is 2322 \rightarrow 3 \rightarrow 2.
  • 4,{0,1,1,1}\langle 4, \{0, 1, 1, 1\}\rangle: The robot ends at coop 44 and the number of pellets each coop gets is {0,1,1,1}\{0, 1, 1, 1\}. The robot's movement is 2342 \rightarrow 3 \rightarrow 4.

输入格式

Input contains three integers NN MM AA (2N1000002 \leq N \leq 100 000; 1M2000001 \leq M \leq 200 000; 1AN1 \leq A \leq N) representing the number of coops, the number of pellets, and the starting position of the feeder robot, respectively.

输出格式

Output contains an integer in a line representing the non-negative remainder when the number of different pellets distributions is divided by 998244353998 244 353.

4 3 2
3
3 5 2
3
3 6 2
6

提示

Explanation for the sample input/output #2

There are 33 different pellets distributions in this case.

  • 2,{2,3,0}\langle 2, \{2, 3, 0\}\rangle: The robot ends at coop 22 and the number of pellets each coop gets is {2,3,0}\{2, 3, 0\}. The robot's movement is $2 \rightarrow 1 \rightarrow 2 \rightarrow 1 \rightarrow 2$.
  • 2,{0,3,2}\langle 2, \{0, 3, 2\}\rangle: The robot ends at coop 22 and the number of pellets each coop gets is {0,3,2}\{0, 3, 2\}. The robot's movement is $2 \rightarrow 3 \rightarrow 2 \rightarrow 3 \rightarrow 2$.
  • 2,{1,3,1}\langle 2, \{1, 3, 1\}\rangle: The robot ends at coop 22 and the number of pellets each coop gets is {1,3,1}\{1, 3, 1\}. The robot's movement is $2 \rightarrow 1 \rightarrow 2 \rightarrow 3 \rightarrow 2$ or $2 \rightarrow 3 \rightarrow 2 \rightarrow 1 \rightarrow 2$; both of them give the same distribution, i.e. the robot ends at the same coop and each coop gets the same number of pellets in both distributions.

Explanation for the sample input/output #3

There are 66 different pellets distributions in this case: 1,{3,3,0}\langle 1, \{3, 3, 0\}\rangle, 1,{2,3,1}\langle 1, \{2, 3, 1\}\rangle, 3,{2,3,1}\langle 3, \{2, 3, 1\}\rangle, 1,{1,3,2}\langle 1, \{1, 3, 2\}\rangle, 3,{1,3,2}\langle 3, \{1, 3, 2\}\rangle, and 3,{0,3,3}\langle 3, \{0, 3, 3\}\rangle.