結果

問題 No.267 トランプソート
ユーザー momen999momen999
提出日時 2017-04-26 10:02:45
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 1,017 bytes
コンパイル時間 5,213 ms
コンパイル使用メモリ 161,916 KB
実行使用メモリ 7,388 KB
最終ジャッジ日時 2023-10-11 15:06:52
合計ジャッジ時間 6,543 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,152 KB
testcase_01 AC 2 ms
6,632 KB
testcase_02 AC 3 ms
7,048 KB
testcase_03 AC 3 ms
7,044 KB
testcase_04 AC 2 ms
7,024 KB
testcase_05 AC 2 ms
6,640 KB
testcase_06 AC 2 ms
7,096 KB
testcase_07 AC 2 ms
6,668 KB
testcase_08 AC 2 ms
7,148 KB
testcase_09 AC 2 ms
7,272 KB
testcase_10 AC 3 ms
7,220 KB
testcase_11 AC 2 ms
7,236 KB
testcase_12 AC 3 ms
7,380 KB
testcase_13 AC 2 ms
7,260 KB
testcase_14 AC 3 ms
7,288 KB
testcase_15 AC 3 ms
7,388 KB
testcase_16 AC 3 ms
7,276 KB
testcase_17 AC 3 ms
7,260 KB
testcase_18 AC 3 ms
7,212 KB
testcase_19 AC 2 ms
7,212 KB
testcase_20 AC 2 ms
7,164 KB
testcase_21 AC 2 ms
7,216 KB
testcase_22 AC 3 ms
7,260 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 Data.List

sortSnd x y | snd x < snd y = LT
            | otherwise     = GT

rInt :: String -> Int
rInt = read

divcards (c:cs) = (c, n)
    where
        n   | head cs == 'A'    = 1
            | head cs == 'T'    = 10
            | head cs == 'J'    = 11
            | head cs == 'Q'    = 12
            | head cs == 'K'    = 13
            | otherwise         = rInt cs

isfstChar c x = c == fst x

sTupleList :: [(Char, Int)] -> [String]
sTupleList [] = []
sTupleList (t:ts) = (fc ++ sc) : sTupleList ts
    where
        fc = [fst t]
        sc  | snd t == 1    = "A"
            | snd t == 10   = "T"
            | snd t == 11   = "J"
            | snd t == 12   = "Q"
            | snd t == 13   = "K"
            | otherwise     = show $ snd t

main = do
    getLine
    cards <- sortBy sortSnd . map divcards . words <$> getLine
    putStrLn $ unwords $ sTupleList $ (filter (isfstChar 'D') cards) ++ (filter (isfstChar 'C') cards) ++ (filter (isfstChar 'H') cards) ++ (filter (isfstChar 'S') cards)
0