結果

問題 No.150 "良問"(良問とは言っていない
ユーザー gigurururugigurururu
提出日時 2015-02-15 15:18:41
言語 Haskell
(9.8.2)
結果
TLE  
(最新)
OLE  
(最初)
実行時間 -
コード長 734 bytes
コンパイル時間 7,459 ms
コンパイル使用メモリ 163,352 KB
実行使用メモリ 17,696 KB
最終ジャッジ日時 2023-09-06 01:16:26
合計ジャッジ時間 19,504 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,543 ms
13,088 KB
testcase_01 AC 4 ms
7,324 KB
testcase_02 AC 12 ms
10,880 KB
testcase_03 AC 12 ms
11,040 KB
testcase_04 AC 12 ms
10,864 KB
testcase_05 AC 152 ms
12,200 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/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
import Debug.Trace

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    = trace (show (1,targetstr,distance,srcstr)) $ diffstr xs distance ys
      | otherwise = trace (show (2,targetstr,distance,srcstr)) $ diffstr xs (distance+1) ys

main = do
  _:sl <- lines <$> getContents
  mapM_ (print . calc) sl
0