結果

問題 No.1335 1337
コンテスト
ユーザー mk
提出日時 2022-01-09 21:50:15
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 2,000 ms
+ 944µs
コード長 861 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 470 ms
コンパイル使用メモリ 184,164 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-20 10:07:27
合計ジャッジ時間 2,167 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#[macro_export]
macro_rules! setup {
    { mut $input:ident: SplitWhitespace $(,)? } => {
        use std::io::Read;
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut $input = buf.split_whitespace();
    };
}

#[macro_export]
macro_rules! parse_next {
    ($str_iter:expr) => {
        $str_iter.next().unwrap().parse().unwrap()
    };
}

fn main() {
    setup! { mut input: SplitWhitespace };

    let a: String = parse_next!(input);
    let s: String = parse_next!(input);

    let map = a.chars().collect::<Vec<_>>();

    let ans = s.chars().fold(String::new(), |acc, c| match c {
        'a'..='z' => acc + &c.to_string(),
        _ => {
            let digit = String::from(c).parse::<usize>().unwrap();
            acc + &map[digit].to_string()
        }
    });

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