結果

問題 No.227 簡単ポーカー
ユーザー kmtrc130kmtrc130
提出日時 2019-03-18 15:40:18
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 5,000 ms
コード長 1,521 bytes
コンパイル時間 4,184 ms
コンパイル使用メモリ 105,552 KB
実行使用メモリ 23,976 KB
最終ジャッジ日時 2023-09-25 13:01:37
合計ジャッジ時間 4,623 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
23,784 KB
testcase_01 AC 59 ms
21,832 KB
testcase_02 AC 59 ms
21,804 KB
testcase_03 AC 58 ms
21,924 KB
testcase_04 AC 59 ms
23,844 KB
testcase_05 AC 59 ms
21,864 KB
testcase_06 AC 60 ms
23,976 KB
testcase_07 AC 59 ms
21,896 KB
testcase_08 AC 59 ms
21,888 KB
testcase_09 AC 59 ms
23,828 KB
testcase_10 AC 59 ms
21,844 KB
testcase_11 AC 58 ms
21,820 KB
testcase_12 AC 59 ms
23,784 KB
testcase_13 AC 59 ms
21,896 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    enum Role
    {
        NO_HAND,
        ONE_PAIR,
        TWO_PAIR,
        THREE_CARD,
        FULL_HOUSE
    }

    public void Solve()
    {
        int[] A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int[] cards = new int[14];
        string ans = DisplayRole(Role.NO_HAND);

        for (int i = 0; i < A.Length; i++)
        { cards[A[i]]++; }

        for (int i = 0; i < cards.Length; i++)
        {
            if (cards[i] == 0) continue;

            if (cards[i] == 2)
            {
                if (ans == DisplayRole(Role.ONE_PAIR)) { ans = DisplayRole(Role.TWO_PAIR); }
                else if (ans == DisplayRole(Role.THREE_CARD)) { ans = DisplayRole(Role.FULL_HOUSE); }
                else
                {
                    ans =
                        DisplayRole(Role.ONE_PAIR);
                }
            }
            else if (cards[i] == 3)
            {
                if (ans == DisplayRole(Role.ONE_PAIR)) { ans = DisplayRole(Role.FULL_HOUSE); }
                else { ans = DisplayRole(Role.THREE_CARD); }
            }
        }

        Console.WriteLine(ans);
    }
    private static string DisplayRole(Role role)
    {
        string[] roleName = { "NO HAND", "ONE PAIR", "TWO PAIR", "THREE CARD", "FULL HOUSE" };
        return roleName[(int)role];
    }

    static void Main()
    {
        var solver = new Program();
        solver.Solve();
    }
}
0