-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHaskellTemplate.hs
More file actions
41 lines (30 loc) · 978 Bytes
/
HaskellTemplate.hs
File metadata and controls
41 lines (30 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-# LANGUAGE FlexibleInstances, UndecidableInstances, DuplicateRecordFields #-}
module Main where
import Control.Monad
import Data.Array
import Data.Bits
import Data.List
import Data.List.Split
import Data.Set
import Debug.Trace
import System.Environment
import System.IO
import System.IO.Unsafe
readMultipleLinesAsStringArray :: Int -> IO [String]
readMultipleLinesAsStringArray 0 = return []
readMultipleLinesAsStringArray n = do
line <- getLine
rest <- readMultipleLinesAsStringArray(n - 1)
return (line : rest)
main :: IO()
main = do
stdout <- getEnv "OUTPUT_PATH"
fptr <- openFile stdout WriteMode
stringsCount <- readLn :: IO Int
strings <- readMultipleLinesAsStringArray stringsCount
queriesCount <- readLn :: IO Int
queries <- readMultipleLinesAsStringArray queriesCount
let res = matchingStrings strings queries
hPutStrLn fptr $ intercalate "\n" $ Data.List.map (\x -> show x) $ res
hFlush fptr
hClose fptr