結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー ShirotsumeShirotsume
提出日時 2022-11-25 21:46:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,133 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 362,156 KB
最終ジャッジ日時 2024-04-10 02:59:36
合計ジャッジ時間 7,888 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
54,716 KB
testcase_01 AC 41 ms
54,616 KB
testcase_02 AC 42 ms
55,872 KB
testcase_03 AC 428 ms
206,048 KB
testcase_04 AC 40 ms
54,936 KB
testcase_05 AC 41 ms
55,576 KB
testcase_06 AC 39 ms
54,684 KB
testcase_07 AC 1,133 ms
362,156 KB
testcase_08 AC 256 ms
147,868 KB
testcase_09 AC 1,100 ms
361,708 KB
testcase_10 AC 1,078 ms
360,836 KB
testcase_11 AC 736 ms
275,532 KB
testcase_12 AC 673 ms
264,384 KB
testcase_13 AC 52 ms
65,120 KB
testcase_14 AC 298 ms
160,044 KB
testcase_15 AC 246 ms
143,980 KB
testcase_16 AC 54 ms
66,548 KB
testcase_17 AC 236 ms
136,772 KB
testcase_18 AC 236 ms
137,712 KB
testcase_19 AC 147 ms
107,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
sys.setrecursionlimit(5 * 10 ** 5)
from pypyjit import set_param
set_param('max_unroll_recursion=-1')
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n = ii()

dp = [[[0] * 3 for _ in range(n // 3 + 2)] for _ in range(n + 1)]

dp[0][0][0] = 1

for i in range(n):
    for j in range(n // 3 + 1):
        for k in range(3):
            if k < 2:
                dp[i + 1][j][(k + 1) % 3] += dp[i][j][k]
            dp[i + 1][j][k] += 25 * dp[i][j][k]
            dp[i + 1][j][k] %= mod
            dp[i + 1][j][(k + 1) % 3] %= mod
        dp[i + 1][j + 1][0] += dp[i][j][k]
        dp[i + 1][j + 1][0] %= mod
ans = 0
for i in range(n//3 + 1):
    for j in range(3):
        ans += i * dp[n][i][j]
        ans %= mod
print(ans)
0