結果

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

ソースコード

diff #
raw source code

n = int(input())
a = input()

while n > 0 and a[0] == '1':
    a = a[1:]
    n -= 1

while n > 0 and a[-1] == '0':
    a = a[:-1]
    n -= 1

if n == 0:
    print(1)
    exit()

# sep = 0
# for i in range(n-1):
#     if a[i:i+2] == "01" or a[i:i+2] == "10":
#         sep += 1
#
m = 998244353
#
# def fac(n):
#     if n == 0: return 1
#     return n * fac(n-1)
#
# def C(n, k):
#     return fac(n)//(fac(n-k)*fac(k))
#
# ans = 2;
# for i in range(1, sep+1, 2):
#     ans += C(n-1, i) % m
#
# print(int(ans % m))

a = a.replace("10", "1,0")
a = a.split(",")
multi = [(len(i)+1)%m for i in a]
ans = 1
for i in multi:
    ans *= i
    ans %= m

print(ans)
0