結果
問題 | No.267 トランプソート |
ユーザー |
![]() |
提出日時 | 2017-01-11 05:01:36 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 29 ms / 1,000 ms |
コード長 | 2,542 bytes |
コンパイル時間 | 1,233 ms |
コンパイル使用メモリ | 116,736 KB |
実行使用メモリ | 18,176 KB |
最終ジャッジ日時 | 2024-12-21 07:23:49 |
合計ジャッジ時間 | 2,708 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;using System.Collections.Generic;using System.Collections.Specialized;using System.Text;using System.Text.RegularExpressions;using System.Linq;using System.IO;class Magatro{static int N;static string[] m;static void Main(){Scan();Array.Sort(m, Compare);Console.WriteLine(string.Join(" ", m));}static int Compare(string a,string b){int atype = Type(a[0]);int btype = Type(b[0]);if (atype > btype) return 1;else if (atype < btype) return -1;else{int anum = Num(a[1]);int bnum = Num(b[1]);return anum.CompareTo(bnum);}}static int Num(char m){switch (m){case 'A':return 1;case 'T':return 10;case 'J':return 11;case 'Q':return 12;case 'K':return 13;}int result;if (int.TryParse(m.ToString(), out result)){return result;}else{throw new Exception();}}static int Type(char m){switch (m){case 'D':return 0;case 'C':return 1;case 'H':return 2;case 'S':return 3;default:throw new Exception();}}static void Scan(){Scanner sc = new Scanner();N = sc.NextInt();m = new string[N];for(int i = 0; i < N; i++){m[i] = sc.Next();}}}public class Scanner{public string[] S;private int Index;private char Separator;public Scanner(char separator=' '){Index = 0;Separator = separator;}private string[] Line(){return Console.ReadLine().Split(Separator);}public string Next(){string result;if (S == null || Index >= S.Length){S = Line();Index = 0;}result = S[Index];Index++;return result;}public int NextInt(){return int.Parse(Next());}public double NextDouble(){return double.Parse(Next());}public long NextLong(){return long.Parse(Next());}}