結果
| 問題 | No.2019 Digits Filling for All Substrings |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-22 22:52:15 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 174 ms / 2,000 ms |
| コード長 | 608 bytes |
| 記録 | |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 81,408 KB |
| 最終ジャッジ日時 | 2026-03-25 15:28:48 |
| 合計ジャッジ時間 | 4,095 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
n = int(input())
S = input()
mod = 998244353
ans = 0
dp = [0]*3
for s in S:
ndp = [0]*3
for i in range(3):
if dp[i] == 0:
continue
for j in range(10):
if s == "?" or int(s) == j:
x = j%3
nx = (x+i)%3
if nx == 0:
ans += dp[i]
ans %= mod
ndp[nx] += dp[i]
ndp[nx] %= mod
for i in range(10):
if s == "?" or int(s) == i:
ndp[i%3] += 1
if i%3 == 0:
ans += 1
dp = ndp
print(ans%mod)