結果

問題 No.2279 OR Insertion
ユーザー shobonvipshobonvip
提出日時 2023-04-21 21:59:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 616 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 80,752 KB
最終ジャッジ日時 2024-04-24 08:06:55
合計ジャッジ時間 17,732 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,480 KB
testcase_01 AC 38 ms
52,992 KB
testcase_02 AC 137 ms
76,636 KB
testcase_03 AC 96 ms
76,544 KB
testcase_04 AC 540 ms
79,796 KB
testcase_05 AC 75 ms
75,136 KB
testcase_06 AC 260 ms
77,244 KB
testcase_07 AC 280 ms
77,800 KB
testcase_08 AC 145 ms
76,260 KB
testcase_09 AC 349 ms
78,116 KB
testcase_10 AC 616 ms
79,356 KB
testcase_11 AC 147 ms
76,544 KB
testcase_12 AC 432 ms
78,732 KB
testcase_13 AC 90 ms
76,032 KB
testcase_14 AC 96 ms
76,416 KB
testcase_15 AC 295 ms
77,616 KB
testcase_16 AC 73 ms
70,272 KB
testcase_17 AC 264 ms
77,248 KB
testcase_18 AC 387 ms
78,416 KB
testcase_19 AC 479 ms
79,176 KB
testcase_20 AC 281 ms
77,240 KB
testcase_21 AC 223 ms
76,948 KB
testcase_22 AC 41 ms
51,968 KB
testcase_23 AC 36 ms
52,096 KB
testcase_24 AC 35 ms
52,224 KB
testcase_25 AC 37 ms
51,840 KB
testcase_26 AC 36 ms
52,096 KB
testcase_27 AC 36 ms
51,968 KB
testcase_28 AC 36 ms
52,224 KB
testcase_29 AC 35 ms
51,840 KB
testcase_30 AC 35 ms
52,224 KB
testcase_31 AC 35 ms
52,096 KB
testcase_32 AC 601 ms
80,024 KB
testcase_33 AC 595 ms
80,504 KB
testcase_34 AC 602 ms
80,752 KB
testcase_35 AC 580 ms
80,572 KB
testcase_36 AC 584 ms
80,560 KB
testcase_37 AC 592 ms
79,804 KB
testcase_38 AC 599 ms
79,808 KB
testcase_39 AC 583 ms
80,560 KB
testcase_40 AC 603 ms
80,536 KB
testcase_41 AC 598 ms
79,772 KB
testcase_42 AC 546 ms
80,500 KB
testcase_43 AC 554 ms
80,504 KB
testcase_44 AC 535 ms
79,736 KB
testcase_45 AC 575 ms
79,976 KB
testcase_46 AC 559 ms
79,848 KB
testcase_47 AC 559 ms
80,496 KB
testcase_48 AC 521 ms
80,344 KB
testcase_49 AC 531 ms
80,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
n = int(input())
s = list(map(int,input()))
# 主客転倒
r = 1
ans = 0
for i in range(1, n+1):
	dp0 = [0] * (n+1)
	dp1 = [0] * (n+1)
	dp0[0] = 1
	dp0s = [0] * (n+1)
	dp1s = [0] * (n+1)
	dp0s[0] = 1
	# j-i 以下から.
	for j in range(n):
		if j-i+1 >= 0:
			dp0[j+1] -= dp0s[j+1-i]
			dp1[j+1] -= dp1s[j+1-i]
			if s[j-i+1] == 0:
				dp0[j+1] += dp0s[j+1-i]
				dp1[j+1] += dp1s[j+1-i]
			else:
				dp1[j+1] += dp0s[j+1-i] + dp1s[j+1-i]
		dp0[j+1] += dp0s[j]
		dp1[j+1] += dp1s[j]
		dp0[j+1] %= mod
		dp1[j+1] %= mod
		dp0s[j+1] += dp0[j+1] + dp0s[j]
		dp1s[j+1] += dp1[j+1] + dp1s[j]
		dp0s[j+1] %= mod
		dp1s[j+1] %= mod
	#print(dp1[n])
	ans += dp1[n] * r
	ans %= mod
	r *= 2
	r %= mod
print(ans)
0