結果

問題 No.1885 Flat Permutation
ユーザー iorioniorion
提出日時 2022-03-25 22:04:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 467 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-22 06:46:12
合計ジャッジ時間 3,590 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 33 ms
10,752 KB
testcase_03 RE -
testcase_04 AC 33 ms
10,752 KB
testcase_05 AC 35 ms
10,752 KB
testcase_06 AC 33 ms
10,752 KB
testcase_07 AC 32 ms
10,752 KB
testcase_08 AC 32 ms
10,880 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 32 ms
10,880 KB
testcase_11 AC 32 ms
10,752 KB
testcase_12 AC 32 ms
10,752 KB
testcase_13 AC 31 ms
10,752 KB
testcase_14 AC 31 ms
10,752 KB
testcase_15 AC 32 ms
10,752 KB
testcase_16 AC 31 ms
10,752 KB
testcase_17 AC 31 ms
10,752 KB
testcase_18 AC 31 ms
10,752 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 32 ms
10,752 KB
testcase_24 AC 30 ms
10,752 KB
testcase_25 AC 32 ms
10,752 KB
testcase_26 AC 30 ms
10,752 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 AC 31 ms
10,752 KB
testcase_33 AC 31 ms
10,752 KB
testcase_34 AC 32 ms
10,752 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 31 ms
10,752 KB
testcase_38 AC 31 ms
10,752 KB
testcase_39 AC 32 ms
10,880 KB
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 998244353

@lru_cache(None)
def solve2(n):
    if n <= 0:
        return 0
    if n <= 3:
        return 1
    return (solve2(n - 1) + solve2(n - 3)) % MOD

def solve(n, x, y):
    if x > y:
        return solve(n, y, x)
    if x > 1:
        return solve(n - x, 1, y - x)
    if y < n:
        return solve(y - 1, x, y - 1)
    return solve2(n)

print(solve(*map(int, input().split())))
0