結果

問題 No.227 簡単ポーカー
ユーザー m0ntBL4Ncm0ntBL4Nc
提出日時 2019-10-20 08:36:41
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,696 bytes
コンパイル時間 1,240 ms
コンパイル使用メモリ 148,776 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 14:33:48
合計ジャッジ時間 2,209 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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];

    for i in 0..cards.len() {
        println!("{}", cards[i]);
    }

    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");
    }
}
0