結果
| 問題 | No.2541 Divide 01 String | 
| コンテスト | |
| ユーザー |  timi | 
| 提出日時 | 2023-12-01 14:34:31 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 79 ms / 2,000 ms | 
| コード長 | 324 bytes | 
| コンパイル時間 | 208 ms | 
| コンパイル使用メモリ | 82,048 KB | 
| 実行使用メモリ | 89,868 KB | 
| 最終ジャッジ日時 | 2024-09-26 15:36:24 | 
| 合計ジャッジ時間 | 2,615 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
N=int(input())
S=input()
if S=='0'*N:
  print(0)
  exit()
from collections import deque
d=deque()
for s in S:
  d.append(s)
  
while d[0]=='0':
  d.popleft()
while d[-1]=='0':
  d.pop()
  
d.popleft()
ans=1;now=0
while d:
  c=d.popleft()
  if c=='0':
    now+=1
  else:
    ans*=now+2
    now=0
    ans%=998244353
print(ans)
            
            
            
        