結果

問題 No.52 よくある文字列の問題
ユーザー ducktailducktail
提出日時 2018-06-03 14:16:11
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 385 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 150,016 KB
最終ジャッジ日時 2024-04-27 02:33:11
合計ジャッジ時間 488 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
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:2:1: error: [GHC-87110]
    Could not load module ‘Data.Set’.
    It is a member of the hidden package ‘containers-0.6.8’.
    Use -v to see a list of the files searched for.
  |
2 | import Data.Set (Set)
  | ^^^^^^^^^^^^^^^^^^^^^

Main.hs:3:1: error: [GHC-87110]
    Could not load module ‘Data.Set’.
    It is a member of the hidden package ‘containers-0.6.8’.
    Use -v to see a list of the files searched for.
  |
3 | import qualified Data.Set as S
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

import Control.Applicative ((<$>))
import Data.Set (Set)
import qualified Data.Set as S

main :: IO ()
main = solve <$> getLine >>= print

solve :: String -> Int
solve =  S.size . f S.empty []
  where f st rs [x] = S.insert (x:rs) st
        f st rs ss = let st1 = f st (head ss : rs) (tail ss)
                         st2 = f st1 (last ss : rs) (init ss)
                     in st2
0