結果

問題 No.3015 右に寄せろ!
コンテスト
ユーザー yamasaKit_
提出日時 2025-01-25 20:50:44
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 974 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 478 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 44,184 KB
最終ジャッジ日時 2026-06-24 09:47:00
合計ジャッジ時間 12,189 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 10 TLE * 1 -- * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import *
from itertools import *
from functools import cache, partial
from pprint import pprint
import sys
from typing import Any, Final

try:
    from icecream import ic
except ImportError:  # Graceful fallback if IceCream isn't installed.
    ic = lambda *a: None if not a else (a[0] if len(a) == 1 else a)  # noqa
debug = partial(print, file=sys.stderr)
dpprint = partial(pprint, stream=sys.stderr)
sys.setrecursionlimit(10**6)
MOD = 998244353

S = list(input())[::-1]
# ic(S)

queue = deque()
queue_zero = deque()
ans = 0
for i, s in enumerate(S):
    queue.append(s)
    if len(queue) < 3:
        continue

    while (
        len(queue) >= 3 and queue[-1] == "1" and queue[-2] == "1" and queue[-3] == "0"
    ):
        ans += 1
        queue.pop()
        queue.pop()
        queue.pop()
        queue.append("1")
        queue.append("1")
        queue_zero.append("0")

    while queue_zero:
        queue.append(queue_zero.popleft())

print(ans)
0