結果

問題 No.267 トランプソート
ユーザー koba-e964koba-e964
提出日時 2015-08-24 00:14:08
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 918 bytes
コンパイル時間 5,260 ms
コンパイル使用メモリ 159,428 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 16:39:55
合計ジャッジ時間 5,854 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashMap;

fn getline() -> String {
  let mut ret = String::new();
  std::io::stdin().read_line(&mut ret).ok();
  return ret;
}

fn parse(s : &str) -> i32 {
  let mut suit = HashMap::new();
  suit.insert('D', 0);
  suit.insert('C', 1);
  suit.insert('H', 2);
  suit.insert('S', 3);
  let mut mark = HashMap::new();
  mark.insert('A', 1);
  mark.insert('T', 10);
  mark.insert('J', 11);
  mark.insert('Q', 12);
  mark.insert('K', 13);
  for i in 2 .. 10 {
    mark.insert((48 + i) as u8 as char, i);
  }
  return suit.get(&s.chars().nth(0).unwrap()).unwrap() + mark.get(&s.chars().nth(1).unwrap()).unwrap();
}


fn main() {
  getline(); // discards n
  let mut cards : Vec<_> = getline().trim().split(" ").map(|x| x.to_string()).collect();
  cards.sort_by(|x, y| parse(x).cmp(&parse(y)));
  for i in 0 .. cards.len() {
    print!("{}{}", cards[i], if i == cards.len() - 1 {"\n"} else {" "});
  }
}
0