結果
| 問題 |
No.267 トランプソート
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2024-10-12 23:56:58 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 1,000 ms |
| コード長 | 2,089 bytes |
| コンパイル時間 | 4,221 ms |
| コンパイル使用メモリ | 112,020 KB |
| 実行使用メモリ | 25,916 KB |
| 最終ジャッジ日時 | 2024-10-12 23:57:04 |
| 合計ジャッジ時間 | 2,858 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = "InputX";
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
//D、C、H、Sの順に並べます
}
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;
}
}
aketijyuuzou