結果

問題 No.3500 01 String
コンテスト
ユーザー naz
提出日時 2026-04-17 22:43:58
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 707 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 735 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 16,092 KB
最終ジャッジ日時 2026-04-17 22:44:16
合計ジャッジ時間 4,545 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_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':
            zeros = 0
            while i < n and s[i] == '0':
                zeros += 1
                i += 1
            
            if i < n and s[i] == '1':
                ones = 0
                while i < n and s[i] == '1':
                    ones += 1
                    i += 1
                
                ans = (ans * (zeros + ones)) % MOD
        else:
            i += 1
            
    print(ans)

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