結果

問題 No.267 トランプソート
ユーザー mbanmban
提出日時 2017-01-11 05:01:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 1,000 ms
コード長 2,542 bytes
コンパイル時間 3,195 ms
コンパイル使用メモリ 107,124 KB
実行使用メモリ 22,832 KB
最終ジャッジ日時 2023-08-23 06:56:34
合計ジャッジ時間 5,939 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
22,764 KB
testcase_01 AC 56 ms
20,676 KB
testcase_02 AC 57 ms
20,704 KB
testcase_03 AC 56 ms
20,648 KB
testcase_04 AC 57 ms
20,724 KB
testcase_05 AC 56 ms
20,724 KB
testcase_06 AC 57 ms
22,688 KB
testcase_07 AC 56 ms
20,772 KB
testcase_08 AC 57 ms
22,728 KB
testcase_09 AC 57 ms
20,684 KB
testcase_10 AC 58 ms
20,740 KB
testcase_11 AC 57 ms
20,732 KB
testcase_12 AC 56 ms
18,688 KB
testcase_13 AC 57 ms
20,660 KB
testcase_14 AC 58 ms
20,676 KB
testcase_15 AC 57 ms
20,748 KB
testcase_16 AC 57 ms
22,788 KB
testcase_17 AC 57 ms
22,824 KB
testcase_18 AC 58 ms
20,688 KB
testcase_19 AC 56 ms
18,752 KB
testcase_20 AC 57 ms
20,772 KB
testcase_21 AC 57 ms
20,748 KB
testcase_22 AC 57 ms
22,832 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;
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());
    }
}
0