結果
| 問題 |
No.267 トランプソート
|
| コンテスト | |
| ユーザー |
sino
|
| 提出日時 | 2020-04-18 12:35:53 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 2,472 bytes |
| コンパイル時間 | 12,817 ms |
| コンパイル使用メモリ | 387,320 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-03 23:29:30 |
| 合計ジャッジ時間 | 13,908 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
#[allow(unused_macros)]
macro_rules! read {
([$t:ty] ; $n:expr) =>
((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
($($t:ty),+ ; $n:expr) =>
((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
([$t:ty]) =>
(rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
($t:ty) =>
(rl().parse::<$t>().unwrap());
($($t:ty),*) => {{
let buf = rl();
let mut w = buf.split_whitespace();
($(w.next().unwrap().parse::<$t>().unwrap()),*)
}};
}
#[allow(dead_code)]
fn rl() -> String {
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).unwrap();
buf.trim_end().to_owned()
}
fn main() {
let _ = read!(usize);
let mut s = read!([String]);
s.sort_by_key(|e| {
let mut key = 0;
let mut chars = e.chars();
match chars.next() {
Some('D') => {
key += 14;
}
Some('C') => {
key += 28;
}
Some('H') => {
key += 42;
}
Some('S') => {
key += 56;
}
_ => unreachable!(),
}
match chars.next() {
Some('A') => {
key += 1;
}
Some('2') => {
key += 2;
}
Some('3') => {
key += 3;
}
Some('4') => {
key += 4;
}
Some('5') => {
key += 5;
}
Some('6') => {
key += 6;
}
Some('7') => {
key += 7;
}
Some('8') => {
key += 8;
}
Some('9') => {
key += 9;
}
Some('T') => {
key += 10;
}
Some('J') => {
key += 11;
}
Some('Q') => {
key += 12;
}
Some('K') => {
key += 13;
}
_ => unreachable!(),
}
key
});
let ans = s.into_iter().fold(String::new(), |mut acc, e| {
acc.push_str(&format!("{} ", e));
acc
});
println!("{}", ans.trim_end());
}
sino