結果

問題 No.2279 OR Insertion
ユーザー tamatotamato
提出日時 2023-04-21 22:00:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 80,640 KB
最終ジャッジ日時 2024-04-24 08:08:21
合計ジャッジ時間 12,665 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 37 ms
52,352 KB
testcase_02 AC 107 ms
76,160 KB
testcase_03 AC 82 ms
76,160 KB
testcase_04 AC 375 ms
79,616 KB
testcase_05 AC 66 ms
76,032 KB
testcase_06 AC 190 ms
77,056 KB
testcase_07 AC 207 ms
77,056 KB
testcase_08 AC 110 ms
76,288 KB
testcase_09 AC 294 ms
77,568 KB
testcase_10 AC 380 ms
80,000 KB
testcase_11 AC 105 ms
76,032 KB
testcase_12 AC 304 ms
78,720 KB
testcase_13 AC 79 ms
76,288 KB
testcase_14 AC 79 ms
76,032 KB
testcase_15 AC 213 ms
77,184 KB
testcase_16 AC 55 ms
68,096 KB
testcase_17 AC 182 ms
76,800 KB
testcase_18 AC 266 ms
78,208 KB
testcase_19 AC 333 ms
79,232 KB
testcase_20 AC 199 ms
77,056 KB
testcase_21 AC 169 ms
76,928 KB
testcase_22 AC 36 ms
52,224 KB
testcase_23 AC 37 ms
51,968 KB
testcase_24 AC 35 ms
51,968 KB
testcase_25 AC 37 ms
51,840 KB
testcase_26 AC 35 ms
51,968 KB
testcase_27 AC 37 ms
51,712 KB
testcase_28 AC 37 ms
52,096 KB
testcase_29 AC 37 ms
51,840 KB
testcase_30 AC 36 ms
51,968 KB
testcase_31 AC 37 ms
51,840 KB
testcase_32 AC 420 ms
80,384 KB
testcase_33 AC 427 ms
80,512 KB
testcase_34 AC 417 ms
80,384 KB
testcase_35 AC 413 ms
80,512 KB
testcase_36 AC 422 ms
80,256 KB
testcase_37 AC 421 ms
80,384 KB
testcase_38 AC 396 ms
80,384 KB
testcase_39 AC 428 ms
80,512 KB
testcase_40 AC 417 ms
80,256 KB
testcase_41 AC 417 ms
80,640 KB
testcase_42 AC 396 ms
80,384 KB
testcase_43 AC 383 ms
80,640 KB
testcase_44 AC 378 ms
80,384 KB
testcase_45 AC 369 ms
80,512 KB
testcase_46 AC 369 ms
80,384 KB
testcase_47 AC 366 ms
80,512 KB
testcase_48 AC 369 ms
80,384 KB
testcase_49 AC 354 ms
80,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
mod = 998244353

N = int(input())
S = input().rstrip('\n')

ans = 0
for k in range(1, N + 1):
    dp = [0] * N
    cs = [0]
    for i in range(N):
        if i + 1 - k < 0:
            dp[i] = (cs[-1] + 1) % mod
        else:
            if S[i + 1 - k] == "0":
                dp[i] = (cs[-1] + 1) % mod
            else:
                dp[i] = (cs[-1] - cs[-k]) % mod
        cs.append((cs[-1] + dp[i]) % mod)
    num = (pow(2, N - 1, mod) - dp[-1]) % mod
    ans = (ans + (num * pow(2, k - 1, mod)) % mod) % mod
    #print(k, num, dp)
print(ans)
0