結果
| 問題 | 
                            No.267 トランプソート
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-06-17 20:38:27 | 
| 言語 | Haskell  (9.10.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 1,000 ms | 
| コード長 | 753 bytes | 
| コンパイル時間 | 2,476 ms | 
| コンパイル使用メモリ | 177,204 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-09 16:57:58 | 
| 合計ジャッジ時間 | 3,380 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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 )
Main.hs:13:1: warning: [GHC-94817] [-Wtabs]
    Tab character found here, and in 8 further locations.
    Suggested fix: Please use spaces instead.
   |
13 |         | and (map isDigit str) = read str
   | ^^^^^^^^
[2 of 2] Linking a.out
            
            ソースコード
import Data.List(sortBy) import Data.Char(isDigit) data Mark = D | C | H | S deriving (Show, Enum, Read) toNum :: String -> Int toNum "A" = 1 toNum "T" = 10 toNum "J" = 11 toNum "Q" = 12 toNum "K" = 13 toNum str | and (map isDigit str) = read str | otherwise = 0 fromNum :: Int -> String fromNum 1 = "A" fromNum 10 = "T" fromNum 11 = "J" fromNum 12 = "Q" fromNum 13 = "K" fromNum x = show x comp :: (Mark, Int) -> (Mark, Int) -> Ordering comp (ma, a) (mb, b) | c /= EQ = c | otherwise = compare a b where c = compare (fromEnum ma) (fromEnum mb) main = do getLine cards <- return . unwords . map (\(m, n) -> show m ++ fromNum n) . sortBy comp . map ((\(m, n) -> (read m :: Mark, toNum n)) . (splitAt 1)) . words =<< getLine putStrLn cards