結果
| 問題 | No.227 簡単ポーカー |
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-02-28 08:24:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 996 bytes |
| コンパイル時間 | 994 ms |
| コンパイル使用メモリ | 83,456 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-16 07:23:57 |
| 合計ジャッジ時間 | 1,642 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
// 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";
}
kichirb3