結果

問題 No.267 トランプソート
ユーザー ducktailducktail
提出日時 2018-05-26 15:58:27
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 865 bytes
コンパイル時間 3,784 ms
コンパイル使用メモリ 175,688 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2023-09-11 03:38:19
合計ジャッジ時間 5,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,880 KB
testcase_01 AC 2 ms
6,868 KB
testcase_02 AC 2 ms
7,056 KB
testcase_03 AC 3 ms
6,816 KB
testcase_04 AC 2 ms
6,836 KB
testcase_05 AC 3 ms
6,784 KB
testcase_06 AC 2 ms
6,956 KB
testcase_07 AC 3 ms
6,900 KB
testcase_08 AC 3 ms
7,576 KB
testcase_09 AC 3 ms
7,600 KB
testcase_10 AC 3 ms
7,552 KB
testcase_11 AC 4 ms
7,556 KB
testcase_12 AC 3 ms
7,552 KB
testcase_13 AC 3 ms
7,716 KB
testcase_14 AC 3 ms
7,448 KB
testcase_15 AC 3 ms
7,704 KB
testcase_16 AC 3 ms
7,592 KB
testcase_17 AC 4 ms
7,516 KB
testcase_18 AC 3 ms
7,516 KB
testcase_19 AC 3 ms
7,508 KB
testcase_20 AC 4 ms
7,556 KB
testcase_21 AC 4 ms
7,584 KB
testcase_22 AC 4 ms
7,568 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative ((<$>))
import Data.List (sort, intercalate)

main :: IO ()
main = getLine >> solve <$> (words <$> getLine) >>= putStrLn

solve :: [String] -> String
solve = intercalate " " . map show . sort . map toTramp

data Mark = D | C | H | S deriving (Eq, Ord, Show, Read)

data Value = Value Int deriving (Eq, Ord)

data Tramp = Tramp Mark Value deriving (Eq, Ord)

instance Show Value where
  show (Value 1) = "A"
  show (Value 10) = "T"
  show (Value 11) = "J"
  show (Value 12) = "Q"
  show (Value 13) = "K"
  show (Value x) = show x

instance Show Tramp where
  show (Tramp m v) = show m ++ show v

toValue :: String -> Value
toValue "A" = Value 1
toValue "T" = Value 10
toValue "J" = Value 11
toValue "Q" = Value 12
toValue "K" = Value 13
toValue x = Value (read x)

toTramp :: String -> Tramp
toTramp [m,v] = Tramp (read [m]) (toValue [v])
0