結果

問題 No.1885 Flat Permutation
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-03-25 23:13:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 81,956 KB
実行使用メモリ 61,816 KB
最終ジャッジ日時 2024-04-22 08:06:54
合計ジャッジ時間 3,089 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,416 KB
testcase_01 AC 37 ms
52,680 KB
testcase_02 AC 39 ms
52,852 KB
testcase_03 AC 43 ms
59,496 KB
testcase_04 AC 39 ms
52,372 KB
testcase_05 AC 34 ms
52,364 KB
testcase_06 AC 38 ms
52,024 KB
testcase_07 AC 40 ms
52,348 KB
testcase_08 AC 35 ms
53,896 KB
testcase_09 AC 35 ms
53,300 KB
testcase_10 AC 35 ms
52,960 KB
testcase_11 AC 34 ms
52,552 KB
testcase_12 AC 34 ms
53,160 KB
testcase_13 AC 34 ms
52,612 KB
testcase_14 AC 36 ms
52,272 KB
testcase_15 AC 34 ms
53,032 KB
testcase_16 AC 35 ms
52,472 KB
testcase_17 AC 39 ms
53,412 KB
testcase_18 AC 38 ms
53,688 KB
testcase_19 AC 42 ms
61,020 KB
testcase_20 AC 40 ms
60,660 KB
testcase_21 AC 41 ms
61,772 KB
testcase_22 AC 40 ms
61,816 KB
testcase_23 AC 35 ms
53,536 KB
testcase_24 AC 34 ms
53,640 KB
testcase_25 AC 35 ms
52,792 KB
testcase_26 AC 34 ms
52,616 KB
testcase_27 AC 41 ms
60,260 KB
testcase_28 AC 40 ms
59,964 KB
testcase_29 AC 40 ms
60,528 KB
testcase_30 AC 41 ms
60,672 KB
testcase_31 AC 43 ms
61,568 KB
testcase_32 AC 37 ms
52,760 KB
testcase_33 AC 36 ms
53,244 KB
testcase_34 AC 35 ms
51,996 KB
testcase_35 AC 41 ms
61,068 KB
testcase_36 AC 42 ms
61,436 KB
testcase_37 AC 34 ms
53,188 KB
testcase_38 AC 36 ms
53,696 KB
testcase_39 AC 37 ms
53,364 KB
testcase_40 AC 38 ms
59,860 KB
testcase_41 AC 40 ms
59,456 KB
testcase_42 AC 38 ms
59,492 KB
testcase_43 AC 40 ms
60,768 KB
testcase_44 AC 41 ms
61,316 KB
testcase_45 AC 41 ms
59,868 KB
testcase_46 AC 41 ms
61,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if x > y:
    x,y = y,x

start = x+1
if x != 1 and x+1 == y:
    if y == n:
        print(1)
    else:
        print(0)
    exit()

end = y-1

dif = end-start

if y == 1 or y == n:
    dif += 1
if x == 1 or x == n:
    dif += 1

dp = [0]*(dif+1)
dp[0] = 1
for i in range(dif):
    dp[i+1] += dp[i]
    dp[i+1] %= mod
    if i+3 <= dif:
        dp[i+3] += dp[i]
        dp[i+3] %= mod
print(dp[-1]%mod)
0