結果

問題 No.2279 OR Insertion
ユーザー sotanishysotanishy
提出日時 2023-04-21 22:53:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 419 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 77,696 KB
最終ジャッジ日時 2024-04-24 08:56:07
合計ジャッジ時間 12,729 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,968 KB
testcase_01 AC 43 ms
52,352 KB
testcase_02 AC 117 ms
76,416 KB
testcase_03 AC 86 ms
75,648 KB
testcase_04 AC 355 ms
77,056 KB
testcase_05 AC 67 ms
67,072 KB
testcase_06 AC 186 ms
76,672 KB
testcase_07 AC 195 ms
76,544 KB
testcase_08 AC 115 ms
76,416 KB
testcase_09 AC 244 ms
76,928 KB
testcase_10 AC 344 ms
77,312 KB
testcase_11 AC 103 ms
76,544 KB
testcase_12 AC 308 ms
77,568 KB
testcase_13 AC 80 ms
73,728 KB
testcase_14 AC 91 ms
76,288 KB
testcase_15 AC 218 ms
76,928 KB
testcase_16 AC 66 ms
65,152 KB
testcase_17 AC 193 ms
76,800 KB
testcase_18 AC 272 ms
76,544 KB
testcase_19 AC 337 ms
76,928 KB
testcase_20 AC 206 ms
76,928 KB
testcase_21 AC 166 ms
76,800 KB
testcase_22 AC 42 ms
52,096 KB
testcase_23 AC 42 ms
51,968 KB
testcase_24 AC 42 ms
51,712 KB
testcase_25 AC 42 ms
51,968 KB
testcase_26 AC 43 ms
52,096 KB
testcase_27 AC 42 ms
51,840 KB
testcase_28 AC 42 ms
52,352 KB
testcase_29 AC 42 ms
51,968 KB
testcase_30 AC 43 ms
51,968 KB
testcase_31 AC 43 ms
51,712 KB
testcase_32 AC 388 ms
77,312 KB
testcase_33 AC 412 ms
77,568 KB
testcase_34 AC 380 ms
77,184 KB
testcase_35 AC 394 ms
77,312 KB
testcase_36 AC 396 ms
77,696 KB
testcase_37 AC 419 ms
77,312 KB
testcase_38 AC 414 ms
77,696 KB
testcase_39 AC 390 ms
77,440 KB
testcase_40 AC 377 ms
77,568 KB
testcase_41 AC 407 ms
77,696 KB
testcase_42 AC 386 ms
77,568 KB
testcase_43 AC 387 ms
77,696 KB
testcase_44 AC 387 ms
77,312 KB
testcase_45 AC 315 ms
77,312 KB
testcase_46 AC 320 ms
77,440 KB
testcase_47 AC 318 ms
77,184 KB
testcase_48 AC 384 ms
77,440 KB
testcase_49 AC 306 ms
77,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod = 998244353
N = int(input())
S = list(map(int, input().rstrip()))
pow2 = [1]*N
for i in range(1, N):
    pow2[i] = 2*pow2[i-1] % mod
ans = 0
for k in range(N):
    dp = [0] * (N+1)
    dp[0] = 1
    cumsum = [0] * (N+2)
    cnt = 0
    for i in range(1, N+1):
        cumsum[i] = (cumsum[i-1] + dp[i-1]) % mod

        if i-k-1 >= 0 and S[i-k-1] == 1:
            dp[i] = (cumsum[i] - cumsum[i-k]) % mod
            cnt = (cnt + cumsum[i-k] * pow2[max(0, N-i-1)]) % mod
        else:
            dp[i] = cumsum[i]
    ans = (ans + cnt * pow2[k]) % mod
print(ans)
0