結果
問題 |
No.1654 Binary Compression
|
ユーザー |
![]() |
提出日時 | 2025-06-12 15:00:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,217 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 82,596 KB |
実行使用メモリ | 310,564 KB |
最終ジャッジ日時 | 2025-06-12 15:01:02 |
合計ジャッジ時間 | 5,784 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | WA * 7 TLE * 1 -- * 42 |
ソースコード
import sys from collections import defaultdict MOD = 924844033 def main(): s = sys.stdin.readline().strip() if not s: print(0) return # Split into runs runs = [] current = s[0] count = 1 for c in s[1:]: if c == current: count += 1 else: runs.append((current, count)) current = c count = 1 runs.append((current, count)) dp = defaultdict(int) dp[0] = 1 for block in runs: char, length = block if char == '0': new_dp = defaultdict(int) for m in dp: p = dp[m] # Option 1: keep the 0 run new_dp[0] = (new_dp[0] + p * length) % MOD # Option 2: remove the 0 run new_dp[m] = (new_dp[m] + p) % MOD dp = new_dp else: new_dp = defaultdict(int) for m in dp: p = dp[m] new_m = m + length new_dp[new_m] = (new_dp[new_m] + p) % MOD dp = new_dp total = 0 for m in dp: total = (total + dp[m] * m) % MOD print(total % MOD) if __name__ == "__main__": main()