結果

問題 No.267 トランプソート
ユーザー 明智重蔵明智重蔵
提出日時 2015-09-19 07:15:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 56 ms / 1,000 ms
コード長 2,039 bytes
コンパイル時間 3,247 ms
コンパイル使用メモリ 104,652 KB
実行使用メモリ 22,624 KB
最終ジャッジ日時 2023-09-26 13:31:40
合計ジャッジ時間 4,562 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,568 KB
testcase_01 AC 53 ms
20,500 KB
testcase_02 AC 54 ms
22,624 KB
testcase_03 AC 53 ms
20,624 KB
testcase_04 AC 54 ms
20,652 KB
testcase_05 AC 55 ms
22,620 KB
testcase_06 AC 54 ms
20,508 KB
testcase_07 AC 54 ms
20,576 KB
testcase_08 AC 54 ms
18,504 KB
testcase_09 AC 54 ms
20,628 KB
testcase_10 AC 54 ms
22,624 KB
testcase_11 AC 54 ms
20,488 KB
testcase_12 AC 53 ms
20,508 KB
testcase_13 AC 54 ms
20,436 KB
testcase_14 AC 54 ms
22,580 KB
testcase_15 AC 54 ms
20,560 KB
testcase_16 AC 56 ms
22,552 KB
testcase_17 AC 55 ms
20,616 KB
testcase_18 AC 55 ms
20,588 KB
testcase_19 AC 55 ms
22,592 KB
testcase_20 AC 55 ms
20,480 KB
testcase_21 AC 55 ms
20,532 KB
testcase_22 AC 54 ms
18,604 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;

class Program
{
    static string InputPattern = "Input4";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4");
            WillReturn.Add("H2 D2 S2 C2");
            //D2 C2 H2 S2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5");
            WillReturn.Add("ST SA SK SQ SJ");
            //SA ST SJ SQ SK
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6");
            WillReturn.Add("S4 SA C5 C4 CA DA");
            //DA CA C4 C5 SA S4
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        string[] CardArr = InputList[1].Split(' ');
        int UB = CardArr.GetUpperBound(0);

        Array.Sort(CardArr, (A, B) =>
        {
            int A_P1 = DeriveMarkPriority(A), A_P2 = DeriveNumPriority(A);
            int B_P1 = DeriveMarkPriority(B), B_P2 = DeriveNumPriority(B);

            int wkInt = A_P1.CompareTo(B_P1);
            if (wkInt != 0) return wkInt;
            return A_P2.CompareTo(B_P2);
        });

        Console.WriteLine(string.Join(" ", CardArr));
    }

    //マークのプライオリティを返す
    static int DeriveMarkPriority(string pStr)
    {
        if (pStr[0] == 'D') return 1;
        if (pStr[0] == 'C') return 2;
        if (pStr[0] == 'H') return 3;
        if (pStr[0] == 'S') return 4;
        return 0;
    }

    //数字のプライオリティを返す
    static int DeriveNumPriority(string pStr)
    {
        if (pStr[1] == 'A') return 1;
        if (pStr[1] == 'T') return 10;
        if (pStr[1] == 'J') return 11;
        if (pStr[1] == 'Q') return 12;
        if (pStr[1] == 'K') return 13;
        return pStr[1] - '2' + 2;
    }
}
0