QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 2048 MB 總分: 100

#5532. 袋鼠

统计

花园由一排编号为 $1$ 到 $N$ 的单元格组成。最初,所有单元格中都有植物。一只袋鼠到达了编号为 $cs$ 的单元格。随后,它在单元格之间跳跃,并沿途吃掉植物。它最终总会在编号为 $cf$ 的单元格结束,且恰好访问每个单元格各一次(包括 $cs$ 和 $cf$)。显然,袋鼠总共会进行 $N-1$ 次跳跃。

袋鼠不想被抓住,因此在每次跳跃后,它都会改变下一次跳跃的方向:如果它当前位于编号为 $current$ 的单元格,且是从编号为 $prev$ 的单元格跳过来的,并准备从 $current$ 跳到编号为 $next$ 的单元格,那么:

  • 如果 $prev < current$,则 $next < current$;否则,
  • 如果 $current < prev$,则 $current < next$。

给定花园中单元格的数量 $N$、袋鼠开始吃植物的起始单元格 $cs$ 以及结束的最终单元格 $cf$,请计算袋鼠在花园中跳跃时可以采取的不同路径数量。

输入格式

输入包含三个由空格分隔的正整数 $N, cs, cf$。

输出格式

输出一个整数,表示袋鼠可以采取的不同路径数量,结果对 $1000000007$ ($10^9 + 7$) 取模。

数据范围

  • $2 \le N \le 2000$
  • $1 \le cs \le N$
  • $1 \le cf \le N$
  • $cs \neq cf$
  • 对于分值为 $6$ 分的测试点,$N \le 8$。
  • 对于分值为 $36$ 分的测试点,$N \le 40$。
  • 对于分值为 $51$ 分的测试点,$N \le 200$。
  • 任何路径都由访问单元格的顺序唯一确定。
  • 保证每个测试点至少存在一条符合规则的路径。
  • 袋鼠可以从 $cs$ 向任意方向开始跳跃。

样例

样例输入 1

4 2 3

样例输出 1

2

说明 1

袋鼠从单元格 $2$ 开始,在单元格 $3$ 结束。两条正确的路径分别是 $2 \to 1 \to 4 \to 3$ 和 $2 \to 4 \to 1 \to 3$。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download
#860EditorialOpen线性做法alpha10222026-01-28 02:29:44View

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.