結果

問題 No.349 干支の置き物
ユーザー ducktailducktail
提出日時 2018-02-08 14:14:24
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 572 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 142,708 KB
最終ジャッジ日時 2023-10-22 06:24:35
合計ジャッジ時間 2,970 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:4:1: error:
    Could not load module ‘Data.ByteString.Char8’
    It is a member of the hidden package ‘bytestring-0.11.4.0’.
    You can run ‘:set -package bytestring’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
4 | import Data.ByteString.Char8 (ByteString)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Main.hs:5:1: error:
    Could not load module ‘Data.ByteString.Char8’
    It is a member of the hidden package ‘bytestring-0.11.4.0’.
    You can run ‘:set -package bytestring’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
5 | import qualified Data.ByteString.Char8 as B
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

import Control.Applicative ((<$>))
import Control.Monad (replicateM)

import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

import Data.List

main :: IO ()
main = do
  n <- readLn
  solve n <$> replicateM n B.getLine >>= putStrLn

solve :: Int -> [ByteString] -> String
solve n ss = f 0 ls
  where
    ls = map length . group . sort $ ss
    f mx xs
      | null xs && mx == 0 = "YES"
      | null xs = "NO"
      | mx == 0 = f (m - 1) rs
      | otherwise = f (m - 1) (mx : rs)
      where
        m = maximum xs
        rs = delete m xs
0