#P5999. [CEOI 2016] kangaroo

[CEOI 2016] kangaroo

Description

There is a garden with nn bushes in a line, numbered 1n1 \sim n. A kangaroo starts from ss, and each time it jumps one step to a different bush, visiting every bush exactly once, and finally arrives at tt. Obviously, it will jump n1n - 1 times. In order not to be discovered by humans, the direction of each jump must be different from the previous one.

More specifically, if it is currently at nownow, it jumped from prevprev to reach nownow, and then it jumps to nextnext:

  • If prev<nowprev < now, then it must hold that next<nownext < now.
  • If now<prevnow < prev, then it must hold that now<nextnow < next.

Ask for the number of valid routes from ss to tt modulo 109+710^9 + 7.

Two routes are different if and only if the visiting order of the bushes is different.

It is guaranteed that there is at least one valid route.

At the beginning, it may jump in any direction.

Input Format

One line with three integers n,s,tn, s, t.

Output Format

One line with one integer, representing the answer.

4 2 3
2

Hint

For 100%100\% of the testdata, 2n2×1032 \le n \le 2 \times 10^3, 1s,tn1 \le s, t \le n.

Translated by ChatGPT 5