結果

問題 No.1885 Flat Permutation
ユーザー puznekopuzneko
提出日時 2022-04-05 23:29:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 77,940 KB
最終ジャッジ日時 2023-08-18 05:32:06
合計ジャッジ時間 6,378 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,648 KB
testcase_01 AC 70 ms
71,592 KB
testcase_02 AC 70 ms
71,496 KB
testcase_03 AC 75 ms
76,260 KB
testcase_04 AC 75 ms
71,548 KB
testcase_05 AC 73 ms
71,464 KB
testcase_06 AC 72 ms
71,412 KB
testcase_07 AC 70 ms
71,212 KB
testcase_08 AC 71 ms
71,652 KB
testcase_09 AC 71 ms
71,588 KB
testcase_10 AC 71 ms
71,396 KB
testcase_11 AC 71 ms
71,468 KB
testcase_12 AC 70 ms
71,232 KB
testcase_13 AC 72 ms
71,412 KB
testcase_14 AC 71 ms
71,224 KB
testcase_15 AC 71 ms
71,588 KB
testcase_16 AC 70 ms
71,504 KB
testcase_17 AC 71 ms
71,368 KB
testcase_18 AC 74 ms
71,596 KB
testcase_19 AC 78 ms
77,564 KB
testcase_20 AC 77 ms
77,716 KB
testcase_21 AC 78 ms
77,940 KB
testcase_22 AC 77 ms
77,748 KB
testcase_23 AC 74 ms
71,420 KB
testcase_24 AC 72 ms
71,304 KB
testcase_25 AC 71 ms
71,228 KB
testcase_26 AC 70 ms
71,472 KB
testcase_27 AC 79 ms
77,724 KB
testcase_28 AC 80 ms
77,776 KB
testcase_29 AC 79 ms
77,692 KB
testcase_30 AC 79 ms
77,616 KB
testcase_31 AC 80 ms
77,656 KB
testcase_32 AC 73 ms
71,168 KB
testcase_33 AC 73 ms
71,408 KB
testcase_34 AC 71 ms
71,408 KB
testcase_35 AC 78 ms
77,724 KB
testcase_36 AC 78 ms
77,604 KB
testcase_37 AC 71 ms
71,432 KB
testcase_38 AC 73 ms
71,504 KB
testcase_39 AC 72 ms
71,704 KB
testcase_40 AC 74 ms
76,420 KB
testcase_41 AC 76 ms
76,628 KB
testcase_42 AC 77 ms
76,068 KB
testcase_43 AC 82 ms
77,764 KB
testcase_44 AC 79 ms
77,552 KB
testcase_45 AC 78 ms
77,676 KB
testcase_46 AC 79 ms
77,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x, y = map(int, input().split())
if x > y:
    x, y = y, x
if y - x == 1:
    if (x == 1) | (y == n):
        print("{}".format(1))
    else:
        print("{}".format(0))
    exit()

m = y - x - 1
if x == 1:
    m += 1
if y == n:
    m += 1
dp = [0 for i in range(m)]
dp[0] = 1
p = 998244353
for i in range(1,m):
    if i >= 3:
        dp[i] = (dp[i-1] + dp[i-3]) % p
    else:
        dp[i] = dp[i-1]

ans = dp[m-1]
print("{}".format(ans))
0