結果
| 問題 | No.227 簡単ポーカー | 
| コンテスト | |
| ユーザー |  nakapa | 
| 提出日時 | 2018-08-26 18:20:19 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,842 bytes | 
| コンパイル時間 | 578 ms | 
| コンパイル使用メモリ | 66,264 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-01 03:57:56 | 
| 合計ジャッジ時間 | 1,116 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 14 | 
ソースコード
#include <iostream>
#include <sstream>
#include <istream>
#include <vector>
using namespace std;
enum PokerHAND{
  FULL_HOUSE=0,
  THREE_CARD=1,
  TWO_PAIR=2,
  ONE_PAIR=3,
  NO_HAND=4
};
// input sample
// 5 6 5 6 5
int judgePoker(){
  std::string str;
  std::string buf;
  std::vector <int> deck;
//  std::cout << "Please input cards"<< std::endl;
  getline(cin, str);
//  std::cout << "Input cards: "<< str <<std::endl;
  int cnt[13] = {};
  int flg_three = 0;
  int flg_two = 0;
  int result = NO_HAND;
  std::stringstream ss{str};
  while(getline(ss, buf, ' '))
  {
    deck.push_back(std::stoi(buf));
  }
  //cout << vec[0];
  for (std::vector<int>::const_iterator i = deck.begin(); i != deck.end(); ++i)
  {
#ifdef DEBUG
    std::cout << *i << ",";
#endif
    cnt[*i-1]++;
  }
#ifdef DEBUG
  std::cout << std::endl;
#endif
  if(deck.size() != 5){
    return -1;
  }
  for (int j = 0; j<13 ;j++)
  {
#ifdef DEBUG
    std::cout <<j<< ": "<< cnt[j] << std::endl;
#endif
    if (cnt[j] == 3){
#ifdef DEBUG
      std::cout << "three: "<< j << std::endl;
#endif
      flg_three = 1;
    }
    else if (cnt[j] == 2) {
#ifdef DEBUG
      std::cout << "two: "<< j << std::endl;
#endif
      flg_two++;
    }
  }
#ifdef DEBUG
  std::cout << "flg_three: "<< flg_three << std::endl;
  std::cout << "flg_two: "<< flg_two << std::endl;
#endif
  if     (flg_three == 1 && flg_two == 1) {cout << "FULL HOUSE"<< endl;}
  else if(flg_three == 1 && flg_two == 0) {cout << "THREE CARD"<< endl;}
  else if(flg_three == 0 && flg_two == 2) {cout << "TWO PAIR"<< endl;}
  else if(flg_three == 0 && flg_two == 1) {cout << "ONE PAIR"<< endl;}
  else                                    {cout << "NO HAND"<< endl;}
  return 0;
}
int main(){
  if (judgePoker()== -1){
    std::cout << "Wrong input" << std::endl;
    return -1;
  }
  return 0;
}
            
            
            
        