結果

問題 No.3015 右に寄せろ!
ユーザー The_Bouningeeeen
提出日時 2025-01-25 14:22:30
言語 Rust
(1.83.0 + proconio)
結果
TLE  
実行時間 -
コード長 601 bytes
コンパイル時間 26,733 ms
コンパイル使用メモリ 391,740 KB
実行使用メモリ 32,396 KB
最終ジャッジ日時 2025-01-25 23:18:10
合計ジャッジ時間 51,567 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 TLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::{input, marker::Chars};

fn main() {
    input! {
        mut s: Chars,
    }

    s.reverse();
    let mut stack = vec![];
    let mut ans = 0;

    while let Some(ch) = s.pop() {
        stack.push(ch);
        if stack.len() < 3 {
            continue;
        }

        if &stack[stack.len() - 3..] == &['1', '1', '0'] {
            let a = stack.pop().unwrap();
            let b = stack.pop().unwrap();
            let c = stack.pop().unwrap();
            s.push(c);
            s.push(b);
            s.push(a);
            ans += 1;
        }
    }

    println!("{}", ans);
}
0