結果

問題 No.2279 OR Insertion
ユーザー Yaowei LyuYaowei Lyu
提出日時 2023-04-21 22:18:33
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 3,246 ms
コンパイル使用メモリ 274,836 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 08:24:19
合計ジャッジ時間 7,014 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 13 ms
5,376 KB
testcase_03 AC 7 ms
5,376 KB
testcase_04 AC 92 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 37 ms
5,376 KB
testcase_07 AC 43 ms
5,376 KB
testcase_08 AC 14 ms
5,376 KB
testcase_09 AC 53 ms
5,376 KB
testcase_10 AC 90 ms
5,376 KB
testcase_11 AC 11 ms
5,376 KB
testcase_12 AC 70 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 44 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 37 ms
5,376 KB
testcase_18 AC 63 ms
5,376 KB
testcase_19 AC 79 ms
5,376 KB
testcase_20 AC 41 ms
5,376 KB
testcase_21 AC 30 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 110 ms
5,376 KB
testcase_33 AC 103 ms
5,376 KB
testcase_34 AC 105 ms
5,376 KB
testcase_35 AC 103 ms
5,376 KB
testcase_36 AC 104 ms
5,376 KB
testcase_37 AC 103 ms
5,376 KB
testcase_38 AC 101 ms
5,376 KB
testcase_39 AC 107 ms
5,376 KB
testcase_40 AC 115 ms
5,376 KB
testcase_41 AC 105 ms
5,376 KB
testcase_42 AC 113 ms
5,376 KB
testcase_43 AC 114 ms
5,376 KB
testcase_44 AC 113 ms
5,376 KB
testcase_45 AC 91 ms
5,376 KB
testcase_46 AC 93 ms
5,376 KB
testcase_47 AC 96 ms
5,376 KB
testcase_48 AC 119 ms
5,376 KB
testcase_49 AC 91 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr LL mod = 998244353;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string s;
    cin >> n >> s;
    LL ans = 0;
    for (LL k = 1, p = 1; k <= n; k += 1, p = p * 2 % mod) {
        vector<LL> f(n + 1);
        vector<LL> g(n + 1);
        g[0] = 1;
        for (int i = 1; i <= n; i += 1) {
            if (i < k or s[i - k] == '0') {
                g[i] = g[i - 1];
                f[i] = f[i - 1];
            } else {
                f[i] = (f[i - 1] + g[i - k]) % mod;
                g[i] = (g[i - 1] + mod - g[i - k]) % mod;
            }
            f[i] = (f[i] + f[i - 1]) % mod;
            g[i] = (g[i] + g[i - 1]) % mod;
        }
        ans = (ans + (f[n] + mod - f[n - 1]) * p) % mod;
    }
    cout << ans;
}
0