結果

問題 No.150 "良問"(良問とは言っていない
ユーザー gigurururugigurururu
提出日時 2015-02-15 15:24:30
言語 Haskell
(9.8.2)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 672 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 171,520 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-04-19 09:23:54
合計ジャッジ時間 3,625 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,808 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 50 ms
8,192 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 15 ms
7,808 KB
testcase_11 AC 17 ms
8,064 KB
testcase_12 AC 13 ms
8,064 KB
testcase_13 AC 16 ms
7,936 KB
testcase_14 AC 19 ms
7,808 KB
testcase_15 AC 18 ms
7,808 KB
testcase_16 AC 5 ms
7,296 KB
testcase_17 AC 8 ms
7,680 KB
testcase_18 AC 17 ms
7,936 KB
testcase_19 AC 20 ms
7,808 KB
testcase_20 AC 21 ms
8,064 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
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
0