結果

問題 No.729 文字swap
ユーザー seinyan
提出日時 2021-11-05 09:11:28
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 12,949 ms
コンパイル使用メモリ 378,388 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 17:33:46
合計ジャッジ時間 14,050 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut vs: Vec<char> = input_line_string().chars().collect();
    let swap: Vec<usize> = input_line_vc();

    let ch = vs[swap[0]];
    vs[swap[0]] = vs[swap[1]];
    vs[swap[1]] = ch;

    let s: String = vs.iter().collect();
    println!("{}", s);
}

fn input_line_vc<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn input_line_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}
0