結果

問題 No.2019 Digits Filling for All Substrings
ユーザー ShirotsumeShirotsume
提出日時 2022-02-13 11:00:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 645 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 47,892 KB
最終ジャッジ日時 2023-09-11 15:20:26
合計ジャッジ時間 33,528 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,232 KB
testcase_01 AC 16 ms
7,764 KB
testcase_02 AC 17 ms
7,760 KB
testcase_03 AC 17 ms
7,952 KB
testcase_04 AC 1,369 ms
34,056 KB
testcase_05 AC 948 ms
26,360 KB
testcase_06 AC 840 ms
24,256 KB
testcase_07 AC 617 ms
19,776 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 38 ms
8,364 KB
testcase_15 AC 39 ms
8,448 KB
testcase_16 AC 145 ms
10,072 KB
testcase_17 AC 47 ms
8,604 KB
testcase_18 AC 55 ms
8,660 KB
testcase_19 AC 16 ms
7,836 KB
testcase_20 AC 16 ms
7,800 KB
testcase_21 AC 16 ms
7,896 KB
testcase_22 AC 16 ms
7,952 KB
testcase_23 AC 16 ms
7,804 KB
testcase_24 AC 1,905 ms
25,428 KB
testcase_25 TLE -
testcase_26 AC 1,321 ms
20,176 KB
testcase_27 AC 81 ms
11,040 KB
testcase_28 AC 81 ms
10,872 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

s = input()

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


for i in range(n):
    if s[i] == '?':
        for j in range(3):
            for k in range(10):
                dp[i + 1][(j + k) % 3] += dp[i][j]
                dp[i + 1][(j + k) % 3] %= mod
        for k in range(10):
            dp[i + 1][k % 3] += 1
            dp[i + 1][k % 3] %= mod
    else:
        for j in range(3):
            dp[i + 1][(j + int(s[i])) % 3] += dp[i][j]
            dp[i + 1][(j + int(s[i])) % 3] %= mod
        dp[i + 1][int(s[i]) % 3] += 1
ans = 0

for i in range(1, n + 1):
    ans += dp[i][0]
    ans %= mod
print(ans)

    
0