結果

問題 No.314 ケンケンパ
ユーザー noriocnorioc
提出日時 2024-03-20 05:46:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 533 ms / 1,000 ms
コード長 568 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 171,812 KB
最終ジャッジ日時 2024-03-20 05:46:49
合計ジャッジ時間 3,950 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 533 ms
170,272 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 40 ms
53,460 KB
testcase_04 AC 39 ms
53,460 KB
testcase_05 AC 39 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 41 ms
53,460 KB
testcase_08 AC 38 ms
53,460 KB
testcase_09 AC 38 ms
53,460 KB
testcase_10 AC 48 ms
62,232 KB
testcase_11 AC 52 ms
64,340 KB
testcase_12 AC 53 ms
64,340 KB
testcase_13 AC 54 ms
66,432 KB
testcase_14 AC 58 ms
70,552 KB
testcase_15 AC 60 ms
72,616 KB
testcase_16 AC 73 ms
78,296 KB
testcase_17 AC 111 ms
86,188 KB
testcase_18 AC 279 ms
122,424 KB
testcase_19 AC 511 ms
171,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from enum import IntEnum, auto


# ステート遷移
class E(IntEnum):
    K = 0
    KK = auto()
    P = auto()

    def nexts(self):
        match self:
            case E.K: return [E.KK, E.P]
            case E.KK: return [E.P]
            case E.P: return [E.K]
        assert False


MOD = 10 ** 9 + 7
INF = 1 << 60
N = int(input())

dp = [[0] * len(E) for _ in range(N+1)]
dp[0][E.K] = 1
for i in range(N-1):
    for fm in E:
        for to in fm.nexts():
            dp[i+1][to] += dp[i][fm]
            dp[i+1][to] %= MOD

ans = sum(dp[N-1]) % MOD
print(ans)
0