結果

問題 No.3500 01 String
コンテスト
ユーザー 蒸した柿ピー
提出日時 2026-04-18 01:52:49
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
MLE  
実行時間 -
コード長 564 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 789 ms
コンパイル使用メモリ 20,572 KB
実行使用メモリ 1,311,296 KB
最終ジャッジ日時 2026-04-18 01:53:21
合計ジャッジ時間 7,859 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other MLE * 2 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import re

n = int(input())
a = input()
result = 0

blocks = re.findall('0+|1+', a)

def calc(array):
    if len(array) == 1:
        return 1
    pre = 0
    for i in range(len(array)):
        if i == 0:
            if "1" in array[i]:
                continue
        elif i == len(array)-1:
            if "0" in array[i]:
                continue
        else:
            array1 = array[:i-1] + [array[i-1] + array[i-1][0]*len(array[i]) + array[i+1]] + array[i+2:]
            pre += len(array[i]) + calc(array1)
    return pre

print(calc(blocks)%998244353)
0