結果

問題 No.1885 Flat Permutation
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-03-25 23:13:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 78,004 KB
最終ジャッジ日時 2023-08-04 10:25:18
合計ジャッジ時間 5,362 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,652 KB
testcase_01 AC 64 ms
71,364 KB
testcase_02 AC 63 ms
71,576 KB
testcase_03 AC 69 ms
76,344 KB
testcase_04 AC 63 ms
71,416 KB
testcase_05 AC 63 ms
71,140 KB
testcase_06 AC 63 ms
71,524 KB
testcase_07 AC 61 ms
71,460 KB
testcase_08 AC 61 ms
71,140 KB
testcase_09 AC 66 ms
71,516 KB
testcase_10 AC 63 ms
71,512 KB
testcase_11 AC 66 ms
71,600 KB
testcase_12 AC 64 ms
71,340 KB
testcase_13 AC 64 ms
71,476 KB
testcase_14 AC 66 ms
71,304 KB
testcase_15 AC 65 ms
71,408 KB
testcase_16 AC 65 ms
71,472 KB
testcase_17 AC 65 ms
71,600 KB
testcase_18 AC 65 ms
71,584 KB
testcase_19 AC 70 ms
77,772 KB
testcase_20 AC 75 ms
77,652 KB
testcase_21 AC 72 ms
77,632 KB
testcase_22 AC 74 ms
77,620 KB
testcase_23 AC 66 ms
71,600 KB
testcase_24 AC 67 ms
71,140 KB
testcase_25 AC 66 ms
71,264 KB
testcase_26 AC 66 ms
71,460 KB
testcase_27 AC 70 ms
77,628 KB
testcase_28 AC 69 ms
77,908 KB
testcase_29 AC 70 ms
77,760 KB
testcase_30 AC 68 ms
77,916 KB
testcase_31 AC 73 ms
77,776 KB
testcase_32 AC 65 ms
71,520 KB
testcase_33 AC 63 ms
71,560 KB
testcase_34 AC 65 ms
71,632 KB
testcase_35 AC 74 ms
77,920 KB
testcase_36 AC 73 ms
77,784 KB
testcase_37 AC 66 ms
71,388 KB
testcase_38 AC 63 ms
71,660 KB
testcase_39 AC 65 ms
71,452 KB
testcase_40 AC 68 ms
76,612 KB
testcase_41 AC 67 ms
76,940 KB
testcase_42 AC 69 ms
76,352 KB
testcase_43 AC 72 ms
77,772 KB
testcase_44 AC 71 ms
77,900 KB
testcase_45 AC 75 ms
78,004 KB
testcase_46 AC 72 ms
77,876 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