結果
問題 | No.267 トランプソート |
ユーザー | くれちー |
提出日時 | 2017-02-04 22:40:43 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,352 bytes |
コンパイル時間 | 4,733 ms |
コンパイル使用メモリ | 180,224 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-06 14:22:24 |
合計ジャッジ時間 | 3,146 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Data.Char (ord) import Data.List (sort) import Control.Applicative ((<$>)) data Rank = A | Rank Int | T | J | Q | K deriving (Eq, Ord) instance Read Rank where readsPrec _ s = readRank s readRank :: ReadS Rank readRank ('A':s) = [(A, s)] readRank ('T':s) = [(T, s)] readRank ('J':s) = [(J, s)] readRank ('Q':s) = [(Q, s)] readRank ('K':s) = [(K, s)] readRank (c:s) = [(x, s)] where x = Rank $ ord c - ord '0' instance Show Rank where show (Rank x) = show x show A = "A" show T = "T" show J = "J" show Q = "Q" show K = "K" data Suit = D | C | H | S deriving (Eq, Ord, Show) instance Read Suit where readsPrec _ s = readSuit s readSuit :: ReadS Suit readSuit ('D':s) = [(D, s)] readSuit ('C':s) = [(C, s)] readSuit ('H':s) = [(H, s)] readSuit ('S':s) = [(S, s)] data Card = Card Suit Rank deriving (Eq, Ord) instance Read Card where readsPrec _ s = readCard s readCard :: ReadS Card readCard "" = [] readCard s = [(Card suit rank, c2)] where [(suit, c1)] = readSuit s [(rank, c2)] = readRank c1 instance Show Card where show (Card suit rank) = show suit ++ show rank solve :: [Card] -> String solve = unwords . (map show) . sort main = do getLine cs <- map read . words <$> getLine putStrLn $ solve cs