結果

問題 No.3019 YNeos
ユーザー atcoder8
提出日時 2025-02-14 21:36:59
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 569 bytes
コンパイル時間 15,841 ms
コンパイル使用メモリ 401,208 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-16 05:45:58
合計ジャッジ時間 15,475 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main() {
    input! {
        x: String,
        y: String,
    }

    match solve(&x, &y) {
        Some(ans) => println!("{}", ans),
        None => println!("?"),
    }
}

fn solve(x: &str, y: &str) -> Option<String> {
    if x.len() != y.len() && x.len() != y.len() + 1 {
        return None;
    }

    let mut alternate: String = x
        .chars()
        .zip(y.chars())
        .flat_map(|(c1, c2)| [c1, c2])
        .collect();
    if x.len() > y.len() {
        alternate.push(x.chars().last().unwrap());
    }
    Some(alternate)
}
0