結果

問題 No.3500 01 String
コンテスト
ユーザー arahi10
提出日時 2026-09-30 15:56:50
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 73 ms / 2,000 ms
+ 166µs
コード長 406 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 216 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 30,376 KB
最終ジャッジ日時 2026-09-30 15:58:20
合計ジャッジ時間 3,034 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

MOD = 998244353
import collections


def solve(S: str) -> None:
    s = collections.deque(S)
    while s and s[0] == "1":
        s.popleft()
    while s and s[-1] == "0":
        s.pop()
    s = "".join(s).replace("10", "1 0").split()
    result = 1
    for substring in s:
        result = result * (len(substring) + 1) % MOD
    print(result)


if __name__ == "__main__":
    input()
    solve(input())
0