結果
問題 |
No.267 トランプソート
|
ユーザー |
|
提出日時 | 2015-08-28 16:59:24 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 615 bytes |
コンパイル時間 | 8,458 ms |
コンパイル使用メモリ | 173,312 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 15:06:44 |
合計ジャッジ時間 | 9,331 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
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 import Data.List import Data.Monoid main :: IO () main = getLine >> getLine >>= putStrLn . unwords . solve . words solve :: [String] -> [String] solve = sortBy compf compf :: String -> String -> Ordering compf (x : xs) (y : ys) | x `elem` "CD" && y `elem` "CD" = compare (ord y) (ord x) `mappend` compare (read' xs) (read' ys) | otherwise = compare (ord x) (ord y) `mappend` compare (read' xs) (read' ys) compf _ _ = error "compf" read' :: String -> Int read' x | x == "A" = 1 | x == "T" = 10 | x == "J" = 11 | x == "Q" = 12 | x == "K" = 13 | otherwise = read x