結果

問題 No.227 簡単ポーカー
ユーザー kichirb3kichirb3
提出日時 2018-02-28 08:24:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 996 bytes
コンパイル時間 2,566 ms
コンパイル使用メモリ 83,916 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 11:05:04
合計ジャッジ時間 3,407 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// No.227 簡単ポーカー
// https://yukicoder.me/problems/no/227
//
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

string solve(vector<int>& cards);

int main() {
    vector<int> cards(5);
    for (auto i = 0; i < 5; i++) {
        cin >> cards[i];
    }

    string ans = solve(cards);
    cout << ans << endl;
}

string solve(vector<int>& cards) {
    unordered_map<int, int> hand;
    for (auto c: cards) {
        if (hand.find(c) != hand.end())
            hand[c]++;
        else
            hand[c] = 1;
    }

    int three_card = 0;
    int one_pair = 0;
    for (auto h: hand) {
        if (h.second == 3)
            three_card++;
        else if (h.second == 2)
            one_pair++;
    }

    if (three_card && one_pair)
        return "FULL HOUSE";
    else if (three_card)
        return "THREE CARD";
    else if (one_pair == 2)
        return "TWO PAIR";
    else if (one_pair == 1)
        return "ONE PAIR";
    return "NO HAND";
}
0