結果

問題 No.2019 Digits Filling for All Substrings
ユーザー ShirotsumeShirotsume
提出日時 2022-02-08 01:34:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 4,638 ms
コンパイル使用メモリ 262,816 KB
実行使用メモリ 14,468 KB
最終ジャッジ日時 2023-09-04 21:08:35
合計ジャッジ時間 7,116 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 20 ms
10,336 KB
testcase_05 AC 14 ms
8,144 KB
testcase_06 AC 13 ms
7,652 KB
testcase_07 AC 10 ms
6,268 KB
testcase_08 AC 28 ms
14,292 KB
testcase_09 AC 32 ms
14,300 KB
testcase_10 AC 31 ms
14,468 KB
testcase_11 AC 30 ms
14,232 KB
testcase_12 AC 30 ms
14,168 KB
testcase_13 AC 31 ms
14,292 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 18 ms
7,868 KB
testcase_25 AC 25 ms
10,032 KB
testcase_26 AC 13 ms
6,764 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 3 ms
4,384 KB
testcase_29 AC 21 ms
9,380 KB
testcase_30 AC 30 ms
12,188 KB
testcase_31 AC 29 ms
11,848 KB
testcase_32 AC 10 ms
5,868 KB
testcase_33 AC 23 ms
9,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<mint>> dp(n + 1, vector<mint>(3));
    rep(i, n){
        if(s[i] == '?'){
            rep(j, 3){
                rep(k, 10) dp[i + 1][(j + k) % 3] += dp[i][j];
            }
            rep(k, 10) dp[i + 1][k % 3] += 1;
        }
        else{
            rep(j, 3) dp[i + 1][(j + int(s[i]-'0')) % 3] += dp[i][j];
            dp[i + 1][int(s[i]-'0') % 3] += 1;
        }
    }
    mint ans = 0;
    rep(i, n) ans += dp[i + 1][0];
    cout << ans.val() << endl;

}
0