結果

問題 No.267 トランプソート
コンテスト
ユーザー むらため
提出日時 2019-01-19 09:01:09
言語 Nim
(2.2.6)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 565 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,545 ms
コンパイル使用メモリ 68,868 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-22 08:43:48
合計ジャッジ時間 3,457 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #
raw source code

import sequtils,strutils,algorithm

proc sortCard(x,y:string):int =
  proc toN(c:char):int =
    if c == 'A' : return 1
    if c == 'T' : return 10
    if c == 'J' : return 11
    if c == 'Q' : return 12
    if c == 'K' : return 13
    return c.ord - '0'.ord
  proc toA(c:char):int =
    if c == 'D': return 0
    if c == 'C': return 1
    if c == 'H': return 2
    if c == 'S': return 3
  if x[0] != y[0]: return x[0].toA() - y[0].toA()
  return x[1].toN() - y[1].toN()

let n = stdin.readLine().parseInt()
echo stdin.readLine().split().sorted(sortCard).join(" ")
0