結果

問題 No.267 トランプソート
コンテスト
ユーザー tonyu0
提出日時 2020-04-29 02:10:27
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 995 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13,804 ms
コンパイル使用メモリ 194,788 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-20 20:33:34
合計ジャッジ時間 5,015 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<String> = (0..n).map(|_| itr.next().unwrap().to_string()).collect();

    let mut map = std::collections::HashMap::new();
    for i in 0..n {
        let p = map.entry(a[i].clone()).or_insert(false);
        *p = true;
    }

    let mut cnt = 0;
    for a in ['D', 'C', 'H', 'S'].to_vec() {
        for b in [
            'A', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K',
        ]
        .to_vec()
        {
            let p = map.entry(format!("{}{}", a, b)).or_insert(false);
            if *p {
                print!("{}{}", a, b);
                cnt += 1;
                if cnt == n {
                    println!("");
                } else {
                    print!(" ");
                }
            }
        }
    }
}
0