結果

問題 No.3500 01 String
コンテスト
ユーザー naz
提出日時 2026-04-17 22:46:12
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 671 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 847 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 16,116 KB
最終ジャッジ日時 2026-04-17 22:46:24
合計ジャッジ時間 4,870 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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

    res = 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
            if i < n and s[i] == '1':
                while i < n and s[i] == '1':
                    c1 += 1
                    i += 1
                res = (res * (c0 + c1)) % MOD
        else:
            i += 1
            
    print(res)

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