結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 38 ms
53,460 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 39 ms
53,460 KB
testcase_09 AC 39 ms
53,460 KB
testcase_10 AC 48 ms
62,236 KB
testcase_11 AC 52 ms
64,344 KB
testcase_12 AC 53 ms
64,344 KB
testcase_13 AC 54 ms
66,436 KB
testcase_14 AC 60 ms
70,552 KB
testcase_15 AC 75 ms
72,616 KB
testcase_16 AC 73 ms
78,296 KB
testcase_17 AC 108 ms
86,188 KB
testcase_18 AC 282 ms
122,424 KB
testcase_19 AC 525 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):
    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