結果
問題 |
No.267 トランプソート
|
ユーザー |
![]() |
提出日時 | 2015-09-19 07:15:59 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 25 ms / 1,000 ms |
コード長 | 2,039 bytes |
コンパイル時間 | 959 ms |
コンパイル使用メモリ | 106,368 KB |
実行使用メモリ | 17,792 KB |
最終ジャッジ日時 | 2024-07-19 07:52:07 |
合計ジャッジ時間 | 2,359 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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; } }