結果
| 問題 |
No.2541 Divide 01 String
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-24 21:27:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 344 bytes |
| コンパイル時間 | 220 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 86,776 KB |
| 最終ジャッジ日時 | 2024-09-26 08:51:40 |
| 合計ジャッジ時間 | 2,181 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 5 |
ソースコード
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)