結果

問題 No.2541 Divide 01 String
コンテスト
ユーザー PNJ
提出日時 2023-11-24 21:25:26
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 376 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 140 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 59,776 KB
最終ジャッジ日時 2026-04-13 12:09:33
合計ジャッジ時間 1,825 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = lambda: sys.stdin.readline().strip()

def Map():
  return list(map(int,input().split()))

N = int(input())
S = input()
mod = 998244353

ans = 1
f = 0
c = 0
for i in range(N):
  if f:
    if S[i] == '1':
      ans *= (c+1)
      ans %= mod
      c = 1
    else:
      c += 1
  else:
    if S[i] == '1':
      f = 1
      c = 1
if f == 0:
  ans = 0
print(ans)
0