結果
問題 |
No.150 "良問"(良問とは言っていない
|
ユーザー |
|
提出日時 | 2015-02-15 15:24:30 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 50 ms / 5,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 2,234 ms |
コンパイル使用メモリ | 172,800 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2024-10-11 01:53:20 |
合計ジャッジ時間 | 2,609 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
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 Control.Applicative import Control.Monad import Data.List import Data.Maybe calc :: String -> Int calc s = minimum $ map fst $ concatMap (\ (dis,str) -> mapMaybe (diffstr "problem" dis) $ take ((length str)-6) $ tails str ) $ mapMaybe (diffstr "good" 0) $ take ((length s)-10) $ tails s where diffstr :: String -> Int -> String -> Maybe (Int,String) diffstr "" distance srcstr = Just (distance,srcstr) diffstr _ _ "" = Nothing diffstr targetstr@(x:xs) distance srcstr@(y:ys) | x == y = diffstr xs distance ys | otherwise = diffstr xs (distance+1) ys main = do _:sl <- lines <$> getContents mapM_ (print . calc) sl