結果

問題 No.227 簡単ポーカー
ユーザー TEWi_RTEWi_R
提出日時 2017-12-17 00:50:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,260 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 67,456 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-14 22:46:39
合計ジャッジ時間 1,408 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,820 KB
testcase_02 AC 2 ms
6,820 KB
testcase_03 AC 1 ms
6,820 KB
testcase_04 AC 2 ms
6,820 KB
testcase_05 AC 2 ms
6,816 KB
testcase_06 AC 2 ms
6,816 KB
testcase_07 AC 2 ms
6,820 KB
testcase_08 AC 2 ms
6,816 KB
testcase_09 AC 1 ms
6,816 KB
testcase_10 AC 2 ms
6,816 KB
testcase_11 AC 1 ms
6,816 KB
testcase_12 AC 2 ms
6,816 KB
testcase_13 AC 1 ms
6,816 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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();

    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