結果
問題 |
No.2019 Digits Filling for All Substrings
|
ユーザー |
👑 |
提出日時 | 2022-07-26 19:53:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 159 ms / 2,000 ms |
コード長 | 454 bytes |
コンパイル時間 | 1,006 ms |
コンパイル使用メモリ | 81,152 KB |
実行使用メモリ | 76,288 KB |
最終ジャッジ日時 | 2024-07-16 10:26:01 |
合計ジャッジ時間 | 4,980 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
MOD = 998244353 n = int(input()) S = input() dp = [0, 0, 0] ans = 0 for s in S: if s == "?": lst = list(range(10)) else: lst = [int(s)] for x in lst: ans += dp[-x % 3] if x % 3 == 0: ans += 1 ans %= MOD ndp = [0] * 3 for x in lst: ndp[x % 3] += 1 for i in range(3): ndp[(i + x) % 3] += dp[i] ndp[(i + x) % 3] %= MOD dp = ndp print(ans)