{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE NegativeLiterals #-}
{-# LANGUAGE HexFloatLiterals #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BlockArguments #-}
-- {-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -O2 #-}
{-# OPTIONS_GHC -Wno-tabs #-}
import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.Extra
import Control.Monad.ST
import Data.Bool
import Data.Bits
import Data.Char
import Data.List
import Data.List.Extra
import Data.Maybe
import Data.Either
import Data.Function
import qualified Data.Set as Set
import qualified Data.IntSet as ISet
import qualified Data.Map as Map
import qualified Data.IntMap as IMap
import qualified Data.Sequence as Seq
import qualified Data.ByteString.Char8 as B
import Data.Array
import Data.Array.ST.Safe
import Data.STRef
import Text.Printf
import Debug.Trace
readInt = fst . fromJust . B.readInt <$> B.getLine
readInteger = fst . fromJust . B.readInteger <$> B.getLine
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine
readStr = trim . B.unpack <$> B.getLine
readStrs = map B.unpack . B.words <$> B.getLine
yesno = bool "No" "Yes"
mp [ a, b ] = ( a, b )
count a as = length $ filter ( == a ) as
modifyArray a i f = writeArray a i =<< f <$> readArray a i
swapArrayElem a i j = do
x <- readArray a i
y <- readArray a j
writeArray a i y
writeArray a j x
a !? i
| inRange ( bounds a ) i = Just $ a ! i
| otherwise = Nothing
printList :: Show a => [a] -> IO ()
printList = putStrLn . intercalate " " . map show
main = do
n <- readInt
ds <- readInts
let
ss = listArray ( 1, n ) $ scanl (+) 0 ds
mapM_ printList do
i <- [ 1 .. n - 1 ]
return do
j <- [ i + 1 .. n ]
return $ ss ! j - ss ! i
app/Main.hs:22:1: warning: [-Wunused-imports]
The import of ‘Control.Applicative’ is redundant
except perhaps to import instances from ‘Control.Applicative’
To import instances alone, use: import Control.Applicative()
|
22 | import Control.Applicative
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:23:1: warning: [-Wunused-imports]
The import of ‘Control.Arrow’ is redundant
except perhaps to import instances from ‘Control.Arrow’
To import instances alone, use: import Control.Arrow()
|
23 | import Control.Arrow
| ^^^^^^^^^^^^^^^^^^^^
app/Main.hs:24:1: warning: [-Wunused-imports]
The import of ‘Control.Monad’ is redundant
except perhaps to import instances from ‘Control.Monad’
To import instances alone, use: import Control.Monad()
|
24 | import Control.Monad
| ^^^^^^^^^^^^^^^^^^^^
app/Main.hs:25:1: warning: [-Wunused-imports]
The import of ‘Control.Monad.Extra’ is redundant
except perhaps to import instances from ‘Control.Monad.Extra’
To import instances alone, use: import Control.Monad.Extra()
|
25 | import Control.Monad.Extra
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:26:1: warning: [-Wunused-imports]
The import of ‘Control.Monad.ST’ is redundant
except perhaps to import instances from ‘Control.Monad.ST’
To import instances alone, use: import Control.Monad.ST()
|
26 | import Control.Monad.ST
| ^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:29:1: warning: [-Wunused-imports]
The import of ‘Data.Bits’ is redundant
except perhaps to import instances from ‘Data.Bits’
To import instances alone, use: import Data.Bits()
|
29 | import Data.Bits
| ^^^^^^^^^^^^^^^^
app/Main.hs:30:1: warning: [-Wunused-imports]
The import of ‘Data.Char’ is redundant
except perhaps to import instances from ‘Data.Char’
To import instances alone, use: import Data.Char()
|
30 | import Data.Char
| ^^^^^^^^^^^^^^^^
app/Main.hs:35:1: warning: [-Wunused-imports]
The import of ‘Data.Either’ is redundant
except perhaps to import instances from ‘Data.Either’
To import instances alone, use: import Data.Either()
|
35 | import Data.Either
| ^^^^^^^^^^^^^^^^^^
app/Main.hs:36:1: warning: [-Wunused-imports]
The import of ‘Data.Function’ is redundant
except perhaps to import instances from ‘Data.Function’
To import instances alone, use: import Data.Function()
|
36 | import Data.Function
| ^^^^^^^^^^^^^^^^^^^^
app/Main.hs:38:1: warning: [-Wunused-imports]
The qualified import of ‘Data.Set’ is redundant
except perhaps to import instances from ‘Data.Set’
To import instances alone, use: import Data.Set()
|
38 | import qualified Data.Set as Set
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:39:1: warning: [-Wunused-imports]
The qualified import of ‘Data.IntSet’ is redundant
except perhaps to import instances from ‘Data.IntSet’
To import instances alone, use: import Data.IntSet()
|
39 | import qualified Data.IntSet as ISet
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:40:1: warning: [-Wunused-imports]
The qualified import of ‘Data.Map’ is redundant
except perhaps to import instances from ‘Data.Map’
To import instances alone, use: import Data.Map()
|
40 | import qualified Data.Map as Map
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:41:1: warning: [-Wunused-imports]
The qualified import of ‘Data.IntMap’ is redundant
except perhaps to import instances from ‘Data.IntMap’
To import instances alone, use: import Data.IntMap()
|
41 | import qualified Data.IntMap as IMap
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:42:1: warning: [-Wunused-imports]
The qualified import of ‘Data.Sequence’ is redundant
except perhaps to import instances from ‘Data.Sequence’
To import instances alone, use: import Data.Sequence()
|
42 | import qualified Data.Sequence as Seq
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:48:1: warning: [-Wunused-imports]
The import of ‘Data.STRef’ is redundant
except perhaps to import instances from ‘Data.STRef’
To import instances alone, use: import Data.STRef()
|
48 | import Data.STRef
| ^^^^^^^^^^^^^^^^^
app/Main.hs:50:1: warning: [-Wunused-imports]
The import of ‘Text.Printf’ is redundant
except perhaps to import instances from ‘Text.Printf’
To import instances alone, use: import Text.Printf()
|
50 | import Text.Printf
| ^^^^^^^^^^^^^^^^^^
app/Main.hs:51:1: warning: [-Wunused-imports]
The import of ‘Debug.Trace’ is redundant
except perhaps to import instances from ‘Debug.Trace’
To import instances alone, use: import Debug.Trace()
|
51 | import Debug.Trace
| ^^^^^^^^^^^^^^^^^^
app/Main.hs:53:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: readInt :: IO Int
|
53 | readInt = fst . fromJust . B.readInt <$> B.getLine
| ^^^^^^^
app/Main.hs:54:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: readInteger :: IO Integer
|
54 | readInteger = fst . fromJust . B.readInteger <$> B.getLine
| ^^^^^^^^^^^
app/Main.hs:54:1: warning: [-Wunused-top-binds]
Defined but not used: ‘readInteger’
|
54 | readInteger = fst . fromJust . B.readInteger <$> B.getLine
| ^^^^^^^^^^^
app/Main.hs:55:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: readInts :: IO [Int]
|
55 | readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
| ^^^^^^^^
app/Main.hs:56:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
readIntegers :: IO [Integer]
|
56 | readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine
| ^^^^^^^^^^^^
app/Main.hs:56:1: warning: [-Wunused-top-binds]
Defined but not used: ‘readIntegers’
|
56 | readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine
| ^^^^^^^^^^^^
app/Main.hs:57:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: readStr :: IO String
|
57 | readStr = trim . B.unpack <$> B.getLine
| ^^^^^^^
app/Main.hs:57:1: warning: [-Wunused-top-binds]
Defined but not used: ‘readStr’
|
57 | readStr = trim . B.unpack <$> B.getLine
| ^^^^^^^
app/Main.hs:58:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: readStrs :: IO [[Char]]
|
58 | readStrs = map B.unpack . B.words <$> B.getLine
| ^^^^^^^^
app/Main.hs:58:1: warning: [-Wunused-top-binds]
Defined but not used: ‘readStrs’
|
58 | readStrs = map B.unpack . B.words <$> B.getLine
| ^^^^^^^^
app/Main.hs:60:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: yesno :: Bool -> String
|
60 | yesno = bool "No" "Yes"
| ^^^^^
app/Main.hs:60:1: warning: [-Wunused-top-binds]
Defined but not used: ‘yesno’
|
60 | yesno = bool "No" "Yes"
| ^^^^^
app/Main.hs:60:14: warning: [-Wtype-defaults]
• Defaulting the type variable ‘a0’ to type ‘String’ in the following constraint
Data.String.IsString a0 arising from the literal ‘"No"’
• In the first argument of ‘bool’, namely ‘"No"’
In the expression: bool "No" "Yes"
In an equation for ‘yesno’: yesno = bool "No" "Yes"
|
60 | yesno = bool "No" "Yes"
| ^^^^
app/Main.hs:61:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: mp :: [b] -> (b, b)
|
61 | mp [ a, b ] = ( a, b )
| ^^
app/Main.hs:61:1: warning: [-Wunused-top-binds]
Defined but not used: ‘mp’
|
61 | mp [ a, b ] = ( a, b )
| ^^
app/Main.hs:61:1: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for ‘mp’:
Patterns of type ‘[b]’ not matched:
[]
[_]
(_:_:_:_)
|
61 | mp [ a, b ] = ( a, b )
| ^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:63:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
count :: Eq a => a -> [a] -> Int
|
63 | count a as = length $ filter ( == a ) as
| ^^^^^
app/Main.hs:63:1: warning: [-Wunused-top-binds]
Defined but not used: ‘count’
|
63 | count a as = length $ filter ( == a ) as
| ^^^^^
app/Main.hs:65:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
modifyArray :: (MArray a1 a2 m, Ix i) =>
a1 i a2 -> i -> (a2 -> a2) -> m ()
|
65 | modifyArray a i f = writeArray a i =<< f <$> readArray a i
| ^^^^^^^^^^^
app/Main.hs:65:1: warning: [-Wunused-top-binds]
Defined but not used: ‘modifyArray’
|
65 | modifyArray a i f = writeArray a i =<< f <$> readArray a i
| ^^^^^^^^^^^
app/Main.hs:66:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
swapArrayElem :: (MArray a e m, Ix i) => a i e -> i -> i -> m ()
|
66 | swapArrayElem a i j = do
| ^^^^^^^^^^^^^
app/Main.hs:66:1: warning: [-Wunused-top-binds]
Defined but not used: ‘swapArrayElem’
|
66 | swapArrayElem a i j = do
| ^^^^^^^^^^^^^
app/Main.hs:71:3: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
(Main.!?) :: Ix i => Array i a -> i -> Maybe a
|
71 | a !? i
| ^^
app/Main.hs:71:3: warning: [-Wunused-top-binds]
Defined but not used: ‘!?’
|
71 | a !? i
| ^^
app/Main.hs:78:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: main :: IO ()
|
78 | main = do
| ^^^^