結果
| 問題 |
No.227 簡単ポーカー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-20 08:38:40 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 1,625 bytes |
| コンパイル時間 | 12,039 ms |
| コンパイル使用メモリ | 390,352 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 17:24:08 |
| 合計ジャッジ時間 | 12,992 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
fn getline() -> String {
let mut __ret = String::new();
std::io::stdin().read_line(&mut __ret).ok();
return __ret;
}
fn main() {
let line = getline();
let params: Vec<_> = line.trim().split(' ').collect();
let mut cards: Vec<usize> = Vec::new();
for i in 0..params.len() {
let card: usize = params[i].parse().unwrap();
cards.push(card);
}
let mut card_counts = vec![0; 14];
let mut is_fullhouse = false;
let mut is_threecard = false;
let mut is_twopair = false;
let mut is_onepair = false;
// count card
for i in 0..cards.len() {
let card_number = cards[i];
card_counts[card_number] += 1;
}
let mut is_three_set = false; // 三枚組か否か
let mut pair_count = 0; // 二枚組の個数
// check hand
for i in 0..card_counts.len() {
if card_counts[i] == 3 {
is_three_set = true;
}
if card_counts[i] == 2 {
pair_count += 1;
}
}
// judge hand
if is_three_set == true {
if pair_count == 1 {
is_fullhouse = true;
} else {
is_threecard = true;
}
} else {
if pair_count == 1 {
is_onepair = true;
} else if pair_count == 2 {
is_twopair = true;
}
}
if is_fullhouse {
println!("FULL HOUSE");
} else if is_threecard {
println!("THREE CARD");
} else if is_twopair {
println!("TWO PAIR");
} else if is_onepair {
println!("ONE PAIR");
} else {
println!("NO HAND");
}
}