結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2024-08-23 01:32:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 655 ms / 1,000 ms |
| コード長 | 808 bytes |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 82,044 KB |
| 実行使用メモリ | 180,036 KB |
| 最終ジャッジ日時 | 2024-08-23 01:32:10 |
| 合計ジャッジ時間 | 4,783 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
from enum import IntEnum, auto
# ステート遷移
class E(IntEnum):
S = 0 # 開始
K = auto() # ケン
KK = auto() # ケンケン
P = auto() # パ
def nexts(self):
match self:
case E.S: return [E.K]
case E.K: return [E.KK, E.P]
case E.KK: return [E.P]
case E.P: return [E.K]
assert False
@staticmethod
def states():
for fm in E:
for to in fm.nexts():
yield fm, to
MOD = 10 ** 9 + 7
N = int(input())
dp = [[0] * len(E) for _ in range(N+1)]
dp[0][E.S] = 1
for i in range(N):
for fm in E:
if dp[i][fm] == 0: continue
for to in fm.nexts():
dp[i+1][to] += dp[i][fm]
dp[i+1][to] %= MOD
ans = sum(dp[N]) % MOD
print(ans)
norioc