結果

問題 No.3500 01 String
コンテスト
ユーザー カプモカ
提出日時 2026-04-17 22:53:19
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 892 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 577 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 128,916 KB
最終ジャッジ日時 2026-04-17 22:54:15
合計ジャッジ時間 8,663 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
import re

N = input().strip()
A = input().strip()

result = 0
dic = [int(A, 2)]
test = [int(A, 2)]
while True:
    target = test[0]
    str_target = bin(target)[2:].zfill(int(N))
    index = [m.start() for m in re.finditer("01", str_target)]
    num = len(index)
    for i in range(num):
        target_ind = index[i]

        target_change1 = str_target[:target_ind] + "1" + str_target[target_ind+1:]
        if not(int(target_change1, 2) in dic):
            dic.append(int(target_change1, 2))
            test.append(int(target_change1, 2))

        target_change0 = str_target[:target_ind+1] + "0" + str_target[target_ind+2:]
        if not(int(target_change0, 2) in dic):
            dic.append(int(target_change0, 2))
            test.append(int(target_change0, 2))

    test.pop(0)
    result += 1
    if test == []:
        break

modulo = result % 998244353
print(modulo)
0