結果

問題 No.1885 Flat Permutation
ユーザー simansiman
提出日時 2022-05-12 17:43:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 294 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 11,172 KB
実行使用メモリ 16,888 KB
最終ジャッジ日時 2023-09-27 17:18:11
合計ジャッジ時間 6,900 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
15,120 KB
testcase_01 AC 68 ms
15,072 KB
testcase_02 AC 69 ms
15,116 KB
testcase_03 AC 71 ms
15,072 KB
testcase_04 AC 69 ms
15,256 KB
testcase_05 AC 70 ms
15,132 KB
testcase_06 AC 69 ms
15,292 KB
testcase_07 AC 69 ms
15,068 KB
testcase_08 AC 71 ms
15,240 KB
testcase_09 AC 70 ms
15,292 KB
testcase_10 AC 71 ms
15,216 KB
testcase_11 AC 70 ms
15,008 KB
testcase_12 AC 69 ms
15,220 KB
testcase_13 AC 70 ms
15,076 KB
testcase_14 AC 69 ms
15,240 KB
testcase_15 AC 69 ms
15,076 KB
testcase_16 AC 69 ms
15,228 KB
testcase_17 AC 70 ms
15,112 KB
testcase_18 AC 68 ms
15,264 KB
testcase_19 AC 112 ms
16,888 KB
testcase_20 AC 109 ms
16,608 KB
testcase_21 AC 112 ms
16,856 KB
testcase_22 AC 107 ms
16,676 KB
testcase_23 AC 70 ms
15,152 KB
testcase_24 AC 70 ms
15,336 KB
testcase_25 AC 68 ms
15,124 KB
testcase_26 AC 68 ms
15,284 KB
testcase_27 AC 111 ms
16,864 KB
testcase_28 AC 113 ms
16,656 KB
testcase_29 AC 111 ms
16,688 KB
testcase_30 AC 111 ms
16,736 KB
testcase_31 AC 112 ms
16,724 KB
testcase_32 AC 69 ms
15,080 KB
testcase_33 AC 68 ms
15,276 KB
testcase_34 AC 69 ms
15,264 KB
testcase_35 AC 111 ms
16,728 KB
testcase_36 AC 113 ms
16,608 KB
testcase_37 AC 70 ms
15,008 KB
testcase_38 AC 70 ms
15,132 KB
testcase_39 AC 73 ms
15,336 KB
testcase_40 AC 80 ms
15,460 KB
testcase_41 AC 87 ms
15,864 KB
testcase_42 AC 77 ms
15,324 KB
testcase_43 AC 111 ms
16,696 KB
testcase_44 AC 113 ms
16,728 KB
testcase_45 AC 111 ms
16,728 KB
testcase_46 AC 115 ms
16,688 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, x, y = gets.split.map(&:to_i)
MOD = 998_244_353

if x > y
  x, y = y, x
end

x += 1 if x != 1
y -= 1 if y != N

d = y - x
dp = Array.new(d + 1, 0)
dp[0] = 1

1.upto(d) do |i|
  dp[i] += dp[i - 1]
  dp[i] += dp[i - 3] if i - 3 >= 0
  dp[i] %= MOD
end

if d < 0
  puts 0
else
  puts dp[d]
end
0