結果

問題 No.1335 1337
コンテスト
ユーザー mk
提出日時 2022-01-09 21:50:15
言語 Rust
(1.93.0 + proconio + num + itertools)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 861 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 21,723 ms
コンパイル使用メモリ 416,056 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-01-14 15:03:49
合計ジャッジ時間 23,196 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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