結果
| 問題 |
No.1654 Binary Compression
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:01:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,217 bytes |
| コンパイル時間 | 256 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 314,764 KB |
| 最終ジャッジ日時 | 2025-06-12 20:05:33 |
| 合計ジャッジ時間 | 6,239 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()
gew1fw