結果
| 問題 |
No.150 "良問"(良問とは言っていない
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-15 15:20:02 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 5,000 ms |
| コード長 | 625 bytes |
| コンパイル時間 | 1,670 ms |
| コンパイル使用メモリ | 171,392 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-10-11 01:52:21 |
| 合計ジャッジ時間 | 2,677 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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) $ tails str ) $ mapMaybe (diffstr "good" 0) $ 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