結果
| 問題 | No.227 簡単ポーカー |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-25 14:36:59 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 1,046 bytes |
| コンパイル時間 | 11,861 ms |
| コンパイル使用メモリ | 377,880 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 17:59:14 |
| 合計ジャッジ時間 | 12,765 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
use std::collections::HashMap;
use std::io::stdin;
fn readln() -> String {
let mut s = String::new();
stdin().read_line(&mut s).unwrap();
s
}
fn main() {
let hand = readln()
.trim()
.split_whitespace()
.map(|card| card.parse::<i32>().unwrap())
.collect::<Vec<i32>>();
let count_map = hand
.into_iter()
.fold(HashMap::new(), |mut hm: HashMap<i32, i32>, card| {
{
let entry = hm.entry(card).or_insert(0);
*entry += 1;
}
hm
});
let count_of_count_map = count_map
.values()
.fold(HashMap::new(), |mut hm: HashMap<i32, i32>, count| {
{
let entry = hm.entry(*count).or_insert(0);
*entry += 1;
}
hm
});
match (count_of_count_map.get(&3), count_of_count_map.get(&2)) {
(Some(&1), Some(&1)) => println!("FULL HOUSE"),
(Some(&1), None ) => println!("THREE CARD"),
(None , Some(&2)) => println!("TWO PAIR"),
(None , Some(&1)) => println!("ONE PAIR"),
_ => println!("NO HAND"),
};
}