結果
問題 | No.430 文字列検索 |
ユーザー | aimy |
提出日時 | 2017-05-13 11:49:35 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 561 bytes |
コンパイル時間 | 1,316 ms |
コンパイル使用メモリ | 164,772 KB |
実行使用メモリ | 8,704 KB |
最終ジャッジ日時 | 2023-10-13 16:16:40 |
合計ジャッジ時間 | 5,155 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
8,072 KB |
testcase_01 | TLE | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
コンパイルメッセージ
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
ソースコード
import Control.Monad import Data.List import Data.Char import Data.IntMap ((!)) import qualified Data.IntMap as M main = do s <- getLine getLine cs <- lines <$> getContents print (searchString s cs) searchString s = sum . map (match s) match s c = length (filter (== (hash c)) (t!(length c))) where t = M.fromDistinctAscList [(k,v) | k <- [1..5000], let v = hashp k s] hash c = sum (zipWith (*) (map (\e -> ord e - 65) c) (iterate (*26) 1)) hashp l s = unfoldr (\(s',l') -> guard (l' >= l) >> Just (hash (take l s'), (tail s', pred l'))) (s, length s)