結果

問題 No.150 "良問"(良問とは言っていない
ユーザー gigurururugigurururu
提出日時 2015-02-15 17:27:25
言語 Haskell
(9.8.2)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 2,937 ms
コンパイル使用メモリ 170,368 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-04-19 09:23:30
合計ジャッジ時間 4,179 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
7,680 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 49 ms
7,936 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 15 ms
7,808 KB
testcase_11 AC 16 ms
7,680 KB
testcase_12 AC 12 ms
7,680 KB
testcase_13 AC 14 ms
7,808 KB
testcase_14 AC 17 ms
7,808 KB
testcase_15 AC 16 ms
7,808 KB
testcase_16 AC 4 ms
6,656 KB
testcase_17 AC 7 ms
7,552 KB
testcase_18 AC 18 ms
7,808 KB
testcase_19 AC 22 ms
7,808 KB
testcase_20 AC 19 ms
7,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import Control.Applicative
import Control.Monad
import Data.List

calc :: String -> Int
calc s = minimum $ map fst $ concatMap (\ (dis,str) -> map (diffstr "problem" dis) $ take ((length str)-6) $ tails str ) $ map (diffstr "good" 0) $ take ((length s)-10) $ tails s
  where
    diffstr :: String -> Int -> String -> (Int,String)
    diffstr "" distance srcstr = (distance,srcstr)
    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
0