結果

問題 No.2541 Divide 01 String
ユーザー sasa8uyauyasasa8uyauya
提出日時 2023-11-24 21:32:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 305 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 89,236 KB
最終ジャッジ日時 2023-11-24 21:32:17
合計ジャッジ時間 2,696 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 54 ms
67,848 KB
testcase_04 AC 65 ms
77,540 KB
testcase_05 AC 78 ms
86,744 KB
testcase_06 AC 67 ms
76,592 KB
testcase_07 AC 78 ms
86,588 KB
testcase_08 AC 85 ms
88,356 KB
testcase_09 AC 82 ms
89,236 KB
testcase_10 AC 75 ms
86,252 KB
testcase_11 AC 78 ms
88,336 KB
testcase_12 AC 76 ms
88,336 KB
testcase_13 AC 35 ms
53,460 KB
testcase_14 AC 34 ms
53,460 KB
testcase_15 AC 33 ms
53,460 KB
testcase_16 AC 33 ms
53,460 KB
testcase_17 AC 34 ms
53,460 KB
testcase_18 AC 58 ms
77,588 KB
testcase_19 AC 59 ms
77,580 KB
testcase_20 AC 59 ms
77,572 KB
testcase_21 AC 55 ms
73,304 KB
testcase_22 AC 55 ms
73,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M=998244353
n=int(input())
s=list(map(int,input()+"0"))
for i in range(n):
  s[i]+=s[i-1]
q=[0]*(n+1)
q[0]=1
q[1]=-1
l=0
for i in range(n+1):
  q[i]+=q[i-1]
  q[i]%=M
  l=max(l,i)
  while l+1<=n and s[l+1-1]-s[i-1]==0:
    l+=1
  if l+1<=n and s[l+1-1]-s[i-1]>0:
    q[l+1]+=q[i]
    q[l+1]%=M
print(q[n])
0