結果

問題 No.3500 01 String
コンテスト
ユーザー Koi
提出日時 2026-04-18 01:01:38
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 535 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 215 ms
コンパイル使用メモリ 85,760 KB
実行使用メモリ 90,752 KB
最終ジャッジ日時 2026-04-18 01:01:48
合計ジャッジ時間 8,020 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

Mod = 998244353
N = int(input())
A = list(input())
A = ["1"] + A
while len(A) > 0 and A[-1] == "0":
    A.pop()
ans = 1
c0 = 0
c1 = 0
is_one = True
for i in range(len(A) - 1, -1, -1):
    # print(c1, c0, A, A[i])
    if(is_one):
        if(A[i] == "1"):
            c1 += 1
        else:
            is_one = False
            c0 += 1
    else:
        if(A[i] == "0"):
            c0 += 1
        else:

            ans *= (c1 + c0 + 1)
            ans %= Mod
            is_one = True
            c0 = 0
            c1 = 1
print(ans)
0