結果

問題 No.2279 OR Insertion
ユーザー とりゐとりゐ
提出日時 2023-04-21 23:28:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 391 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 82,028 KB
実行使用メモリ 78,056 KB
最終ジャッジ日時 2024-04-24 09:25:44
合計ジャッジ時間 11,819 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,352 KB
testcase_01 AC 40 ms
53,248 KB
testcase_02 AC 103 ms
76,148 KB
testcase_03 AC 77 ms
76,148 KB
testcase_04 AC 334 ms
77,312 KB
testcase_05 AC 61 ms
68,864 KB
testcase_06 AC 169 ms
76,416 KB
testcase_07 AC 180 ms
76,416 KB
testcase_08 AC 102 ms
76,524 KB
testcase_09 AC 228 ms
76,748 KB
testcase_10 AC 320 ms
77,032 KB
testcase_11 AC 93 ms
76,416 KB
testcase_12 AC 287 ms
76,928 KB
testcase_13 AC 69 ms
74,880 KB
testcase_14 AC 77 ms
76,416 KB
testcase_15 AC 200 ms
76,648 KB
testcase_16 AC 59 ms
66,304 KB
testcase_17 AC 180 ms
76,524 KB
testcase_18 AC 256 ms
76,872 KB
testcase_19 AC 318 ms
77,032 KB
testcase_20 AC 192 ms
76,456 KB
testcase_21 AC 152 ms
76,468 KB
testcase_22 AC 39 ms
52,480 KB
testcase_23 AC 38 ms
52,352 KB
testcase_24 AC 39 ms
52,224 KB
testcase_25 AC 39 ms
52,096 KB
testcase_26 AC 39 ms
51,840 KB
testcase_27 AC 42 ms
51,840 KB
testcase_28 AC 40 ms
52,224 KB
testcase_29 AC 40 ms
52,224 KB
testcase_30 AC 39 ms
52,224 KB
testcase_31 AC 39 ms
52,352 KB
testcase_32 AC 365 ms
77,548 KB
testcase_33 AC 386 ms
77,312 KB
testcase_34 AC 356 ms
77,760 KB
testcase_35 AC 362 ms
77,272 KB
testcase_36 AC 363 ms
77,352 KB
testcase_37 AC 391 ms
77,524 KB
testcase_38 AC 389 ms
78,056 KB
testcase_39 AC 357 ms
77,312 KB
testcase_40 AC 361 ms
77,720 KB
testcase_41 AC 384 ms
77,568 KB
testcase_42 AC 365 ms
77,568 KB
testcase_43 AC 367 ms
77,312 KB
testcase_44 AC 366 ms
77,356 KB
testcase_45 AC 286 ms
77,312 KB
testcase_46 AC 282 ms
77,496 KB
testcase_47 AC 285 ms
77,380 KB
testcase_48 AC 371 ms
77,380 KB
testcase_49 AC 255 ms
77,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
input=lambda :stdin.readline()[:-1]

n=int(input())
s=input()

mod=998244353
ans=0
pow2=[1]*(n+1)
for i in range(1,n+1):
  pow2[i]=pow2[i-1]*2%mod

for i in range(n):
  dp=[0]*(n+1)
  dp[0]=1
  cum=[0]*(n+2)
  cum[1]=1
  res=1
  for j in range(n):
    if j>=i and s[j-i]=='1':
      ans+=cum[j-i+1]*pow2[max(0,n-2-j)]%mod*pow2[i]
      ans%=mod
      dp[j+1]=cum[j+1]-cum[j-i+1]
    else:
      dp[j+1]=cum[j+1]
    cum[j+2]=cum[j+1]+dp[j+1]
    cum[j+2]%=mod

print(ans%mod)
0