結果
問題 | No.2219 Re:010 |
ユーザー |
|
提出日時 | 2023-02-17 22:20:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 406 ms / 2,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 81,816 KB |
実行使用メモリ | 124,780 KB |
最終ジャッジ日時 | 2024-07-19 13:30:11 |
合計ジャッジ時間 | 5,436 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
S = input() mod = 998244353 L = [[0,0]] for s in S: l = L[-1][:] if s == "0": l[0] += 1 elif s == "?": l[1] += 1 L.append(l) R = [[0,0]] for s in S[::-1]: l = R[-1][:] if s == "0": l[0] += 1 elif s == "?": l[1] += 1 R.append(l) R = R[::-1] ans = 0 for i,s in enumerate(S): if s == "0": continue l0,l1 = L[i] r0,r1 = R[i+1] # print(i,s,l1,l1,r0,r1) ans += l0*r0%mod*pow(2,l1+r1,mod) ans %= mod if r1: ans += l0*r1%mod*pow(2,l1+r1-1,mod) ans %= mod if l1: ans += r0*l1%mod*pow(2,l1+r1-1,mod) ans %= mod if r1*l1: ans += r1*l1%mod*pow(2,l1+r1-2,mod) ans %= mod print(ans)