結果

問題 No.227 簡単ポーカー
ユーザー TEWi_RTEWi_R
提出日時 2017-12-17 00:50:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,320 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 69,756 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-08 17:09:37
合計ジャッジ時間 1,533 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from main.cpp:1:
In static member function ‘static _Tp* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(const _Tp*, const _Tp*, _Tp*) [with _Tp = int; bool _IsMove = false]’,
    inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = const int*; _OI = int*]’ at /usr/include/c++/11/bits/stl_algobase.h:495:30,
    inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = const int*; _OI = int*]’ at /usr/include/c++/11/bits/stl_algobase.h:522:42,
    inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _OI = int*]’ at /usr/include/c++/11/bits/stl_algobase.h:529:31,
    inlined from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _OI = int*]’ at /usr/include/c++/11/bits/stl_algobase.h:620:7,
    inlined from ‘static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _ForwardIterator = int*]’ at /usr/include/c++/11/bits/stl_uninitialized.h:110:27,
    inlined from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _ForwardIterator = int*]’ at /usr/include/c++/11/bits/stl_uninitialized.h:151:15,
    inlined from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int>

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

void printVector(vector<int> v, string delimiter){
    for(int i = 0; i < v.size(); ++i){
        if(i != 0) cout << delimiter;
        cout << v[i];
    }
    cout << '\n';
}

int countMaxCard(vector<int> cards, vector<int> u_cards){
    int count = 0;
    for(auto e_card: u_cards){
        int tmp_count = 0;
        for(auto card: cards){
            if(card == e_card) tmp_count++;
        }
        if(tmp_count > count) count = tmp_count;
    }
    return count;
}

int main(){

    vector<int> cards(5),u_cards(5);
    for(auto&& card: cards) cin >> card;
    sort(cards.begin(), cards.end());
    u_cards = cards;
    u_cards.erase(unique(u_cards.begin(), u_cards.end()), u_cards.end());

    int cards_e = u_cards.size();
    printVector(cards, ",");
    printVector(u_cards, ",");

    if(cards_e == 5){
        puts("NO HAND");
    } else if(cards_e == 4){
        puts("ONE PAIR");
    } else if(cards_e == 3){
        int cnt = countMaxCard(cards, u_cards);
        if(cnt == 3) puts("THREE CARD");
        if(cnt == 2) puts("TWO PAIR");
    } else if(cards_e == 2){
        if(countMaxCard(cards, u_cards) == 3) puts("FULL HOUSE");
        else puts("NO HAND");
    } else {
        puts("NO HAND");
    }

    return 0;
}
0