結果

問題 No.1885 Flat Permutation
ユーザー miscalcmiscalc
提出日時 2021-11-13 16:23:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 16,080 KB
最終ジャッジ日時 2023-09-02 07:39:48
合計ジャッジ時間 4,231 ms
ジャッジサーバーID
(参考情報)
judge16 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,820 KB
testcase_01 AC 16 ms
7,856 KB
testcase_02 AC 15 ms
7,944 KB
testcase_03 AC 18 ms
8,408 KB
testcase_04 AC 16 ms
7,968 KB
testcase_05 AC 15 ms
7,816 KB
testcase_06 AC 16 ms
7,868 KB
testcase_07 AC 16 ms
7,820 KB
testcase_08 AC 15 ms
7,904 KB
testcase_09 AC 16 ms
7,928 KB
testcase_10 AC 15 ms
7,856 KB
testcase_11 AC 16 ms
7,832 KB
testcase_12 AC 15 ms
7,860 KB
testcase_13 AC 16 ms
7,832 KB
testcase_14 AC 16 ms
7,956 KB
testcase_15 AC 15 ms
7,820 KB
testcase_16 AC 15 ms
7,860 KB
testcase_17 AC 15 ms
7,820 KB
testcase_18 AC 16 ms
7,788 KB
testcase_19 AC 102 ms
15,972 KB
testcase_20 AC 101 ms
15,904 KB
testcase_21 AC 102 ms
16,056 KB
testcase_22 AC 89 ms
15,172 KB
testcase_23 AC 15 ms
7,860 KB
testcase_24 AC 16 ms
7,928 KB
testcase_25 AC 15 ms
7,964 KB
testcase_26 AC 16 ms
7,860 KB
testcase_27 AC 103 ms
15,868 KB
testcase_28 AC 103 ms
15,908 KB
testcase_29 AC 101 ms
16,060 KB
testcase_30 AC 103 ms
16,020 KB
testcase_31 AC 103 ms
16,008 KB
testcase_32 AC 15 ms
7,828 KB
testcase_33 AC 15 ms
7,884 KB
testcase_34 AC 16 ms
7,832 KB
testcase_35 AC 101 ms
15,896 KB
testcase_36 AC 102 ms
16,020 KB
testcase_37 AC 16 ms
7,844 KB
testcase_38 AC 16 ms
7,820 KB
testcase_39 AC 15 ms
7,956 KB
testcase_40 AC 30 ms
9,484 KB
testcase_41 AC 51 ms
11,260 KB
testcase_42 AC 22 ms
8,668 KB
testcase_43 AC 102 ms
15,956 KB
testcase_44 AC 101 ms
16,080 KB
testcase_45 AC 102 ms
16,008 KB
testcase_46 AC 104 ms
16,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x, y = map(int, input().split())
mod = 998244353

def sub(d):
  dp = [0] * (d + 1)
  dp[0] = 1
  for i in range(d):
    dp[i + 1] += dp[i]
    dp[i + 1] %= mod
    if i + 3 <= d:
      dp[i + 3] += dp[i]
      dp[i + 3] %= mod
  return dp[d]

if x > y:
  x, y = y, x
x0 = x + (0 if x == 1 else 1)
y0 = y - (0 if y == n else 1)
d = y0 - x0
if d < 0:
  print(0)
else:
  print(sub(d))
0