結果

問題 No.267 トランプソート
ユーザー rlangevin
提出日時 2023-01-14 13:24:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 646 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 53,888 KB
最終ジャッジ日時 2024-12-25 21:20:51
合計ジャッジ時間 2,848 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

def trump(n):
    if n == "A":
        return 1
    elif n =="T":
        return 10
    elif n == "J":
        return 11
    elif n == "Q":
        return 12
    elif n == "K":
        return 13
    else:
        return int(n)

N = int(input())
card = list(input().split())
D = defaultdict(list)
DD = dict()
for s in card:
    DD[trump(s[1])] = s[1]
    D[s[0]].append(trump(s[1]))
    
ans = []
for a in sorted(D["D"]):
    ans.append("D" + DD[a])
for a in sorted(D["C"]):
    ans.append("C" + DD[a])
for a in sorted(D["H"]):
    ans.append("H" + DD[a])
for a in sorted(D["S"]):
    ans.append("S" + DD[a])
print(*ans)
0