問題一覧 > 通常問題

No.1885 Flat Permutation

レベル : / AI推定難易度 : 1750 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 126
作問者 : miscalc / テスター : ygussany Shirotsume
お気に入りにしたユーザー ProblemId : 7290 / 自分の提出
問題文最終更新日: 2022-02-04 20:17:49
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 337 (順位表) の他の問題:

Problem Statement

You are given integers $N, X, Y$. Find the number of permutations $P = (P_1, P_2, \ldots, P_N)$ of $(1, 2, \ldots, N)$ that satisfy all of the following conditions.

  • $P_1 = X$
  • $P_N = Y$
  • $|P_{i+1} - P_i| \leq 2$ ($1 \leq i \leq N - 1$)
Since the answer can be very large, output it modulo $998244353$.

Input

$N$ $X$ $Y$

  • All input values are integers.
  • $2 \leq N \leq 2 \times 10^5$
  • $1 \leq X, Y \leq N$
  • $X \neq Y$

Output

Output the number of $P$ satisfying the conditions, modulo $998244353$. End the output with a newline.

Sample

Sample 1
Input
4 1 4
Output
2

The $2$ permutations $P = (1, 2, 3, 4), (1, 3, 2, 4)$ satisfy the conditions.

Sample 2
Input
6 3 5
Output
1

Only $P = (3, 1, 2, 4, 6, 5)$ satisfies the conditions.

Sample 3
Input
4 3 2
Output
0

No $P$ satisfies the conditions.

Sample 4
Input
31415 9265 3589
Output
889048175

Output the answer modulo $998244353$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。