結果

問題 No.2541 Divide 01 String
ユーザー hiro1729hiro1729
提出日時 2023-11-24 21:27:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 344 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 86,352 KB
最終ジャッジ日時 2023-11-24 21:27:59
合計ジャッジ時間 2,160 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 50 ms
66,352 KB
testcase_04 AC 56 ms
74,940 KB
testcase_05 AC 77 ms
86,164 KB
testcase_06 AC 55 ms
74,432 KB
testcase_07 AC 77 ms
85,604 KB
testcase_08 AC 79 ms
86,296 KB
testcase_09 AC 80 ms
86,352 KB
testcase_10 AC 45 ms
65,864 KB
testcase_11 AC 45 ms
65,860 KB
testcase_12 AC 45 ms
65,860 KB
testcase_13 AC 39 ms
53,460 KB
testcase_14 AC 37 ms
53,460 KB
testcase_15 AC 37 ms
53,460 KB
testcase_16 AC 38 ms
53,460 KB
testcase_17 AC 37 ms
53,460 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def rle(s):
	n = len(s)
	i = 0
	r = []
	while i < n:
		j = i
		while j < n and s[j] == s[i]:
			j += 1
		r.append((s[i], j - i))
		i = j
	return r
n = int(input())
s = input().strip('0')
n = len(s)
ans = 1
for i, j in rle(s):
	if i == '0':
		ans = (ans * (j + 2)) % 998244353
	else:
		ans = ans * pow(2, j - 1, 998244353) % 998244353
print(ans)
0