結果

問題 No.2279 OR Insertion
ユーザー tassei903tassei903
提出日時 2023-04-21 22:13:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 517 ms / 2,000 ms
コード長 967 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 80,640 KB
最終ジャッジ日時 2024-04-24 08:20:08
合計ジャッジ時間 15,014 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,840 KB
testcase_01 AC 44 ms
52,352 KB
testcase_02 AC 128 ms
76,160 KB
testcase_03 AC 89 ms
76,032 KB
testcase_04 AC 466 ms
79,816 KB
testcase_05 AC 70 ms
71,296 KB
testcase_06 AC 231 ms
77,288 KB
testcase_07 AC 233 ms
77,184 KB
testcase_08 AC 126 ms
76,288 KB
testcase_09 AC 292 ms
77,824 KB
testcase_10 AC 437 ms
78,976 KB
testcase_11 AC 119 ms
76,416 KB
testcase_12 AC 362 ms
78,396 KB
testcase_13 AC 87 ms
76,288 KB
testcase_14 AC 95 ms
75,904 KB
testcase_15 AC 271 ms
77,312 KB
testcase_16 AC 65 ms
67,328 KB
testcase_17 AC 221 ms
77,140 KB
testcase_18 AC 333 ms
77,952 KB
testcase_19 AC 416 ms
79,232 KB
testcase_20 AC 251 ms
77,184 KB
testcase_21 AC 201 ms
76,632 KB
testcase_22 AC 42 ms
52,096 KB
testcase_23 AC 42 ms
52,224 KB
testcase_24 AC 41 ms
52,224 KB
testcase_25 AC 41 ms
52,224 KB
testcase_26 AC 43 ms
52,352 KB
testcase_27 AC 41 ms
52,224 KB
testcase_28 AC 41 ms
51,968 KB
testcase_29 AC 40 ms
52,096 KB
testcase_30 AC 40 ms
51,712 KB
testcase_31 AC 43 ms
52,224 KB
testcase_32 AC 478 ms
79,872 KB
testcase_33 AC 514 ms
80,256 KB
testcase_34 AC 483 ms
80,384 KB
testcase_35 AC 511 ms
79,876 KB
testcase_36 AC 509 ms
79,956 KB
testcase_37 AC 505 ms
80,468 KB
testcase_38 AC 504 ms
80,212 KB
testcase_39 AC 511 ms
80,072 KB
testcase_40 AC 491 ms
80,384 KB
testcase_41 AC 517 ms
80,256 KB
testcase_42 AC 476 ms
80,384 KB
testcase_43 AC 465 ms
80,256 KB
testcase_44 AC 471 ms
80,640 KB
testcase_45 AC 428 ms
80,256 KB
testcase_46 AC 433 ms
80,384 KB
testcase_47 AC 436 ms
80,000 KB
testcase_48 AC 450 ms
80,000 KB
testcase_49 AC 437 ms
80,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

ans = 0
mod = 998244353
n = ni()
s = [int(i) for i in input()]

for k in range(1, n+1):
    dp0 = [0] * (n+1)
    dp0[0] = 1
    dp1 = [0] * (n+1)
    rui0 = [0] * (n+1)
    rui0[0] = 1
    rui1 = [0] * (n+1)
    for i in range(1, n+1):
        if i-k >= 0 and s[i-k]:
            dp1[i] = (rui0[i-k]+rui1[i-1])%mod
            dp0[i] = (rui0[i-1]-rui0[i-k])%mod
        else:
            dp1[i] = rui1[i-1]
            dp0[i] = rui0[i-1]
        rui0[i] = (rui0[i-1] + dp0[i])%mod
        rui1[i] = (rui1[i-1] + dp1[i])%mod
    ans += dp1[-1] * pow(2, k-1, mod)%mod
    ans %= mod
    #print(dp1[-1])
print(ans)
0