結果

問題 No.3779 L or R
コンテスト
ユーザー urectanc
提出日時 2026-10-30 22:25:33
言語 Rust
(1.99.0 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 4 ms / 2,000 ms
+ 546µs
コード長 839 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,633 ms
コンパイル使用メモリ 180,016 KB
実行使用メモリ 9,920 KB
最終ジャッジ日時 2026-10-30 22:25:49
合計ジャッジ時間 4,604 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use itertools::Itertools;
use proconio::{input, marker::Bytes};

fn main() {
    input! {
        n: usize,
        s: Bytes,
    }

    if n == 1 && s[0] == b'o' {
        println!("No");
        return;
    }

    for t in 0..2 {
        let mut d = s.windows(2).map(|w| w[0] == w[1]).collect_vec();
        d.push(false);
        if t == 1 {
            d[0] ^= true;
        }
        let mut ans = String::from(if t == 0 { "L" } else { "R" });
        let mut ok = s[0] == b'x';
        for i in 0..n - 1 {
            if d[i] {
                ans.push('R');
                d[i + 1] ^= true;
            } else {
                ans.push('L');
                ok ^= true;
            }
        }

        if ok {
            println!("Yes");
            println!("{ans}");
            return;
        }
    }

    println!("No");
}
0