結果

問題 No.3500 01 String
コンテスト
ユーザー naz
提出日時 2026-04-17 22:49:52
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 657 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 680 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 16,220 KB
最終ジャッジ日時 2026-04-17 22:50:55
合計ジャッジ時間 4,306 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 3 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys

def solve():
    input_data = sys.stdin.read().split()
    if len(input_data) < 2:
        return
    
    n = int(input_data[0])
    s = input_data[1]
    MOD = 998244353

    ans = 1
    i = 0
    while i < n:
        if s[i] == '0':
            c0 = 0
            while i < n and s[i] == '0':
                c0 += 1
                i += 1
            
            c1 = 0
            while i < n and s[i] == '1':
                c1 += 1
                i += 1
            
            if c1 > 0:
                ans = (ans * (c0 + c1)) % MOD
        else:
            i += 1
            
    print(ans)

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