import Control.Monad
import Control.Monad.ST
import Control.Monad.Primitive
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Char
import Data.Ord
import Data.Ix
import Data.Bool
import Data.Vector.Unboxed.Base
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Data.Array
import Data.Array.ST
import Data.Sequence (Seq)
import qualified Data.Sequence as Seq
import qualified Data.Set as Set
import Data.Tree
import qualified Data.Map as M
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap as IM
import qualified Data.Heap as H
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
putStrList xs = putStrLn . unwords $ map show xs
main = do
[n, m] <- getIntList
es <- replicateM m $ do
[u, v, t] <- getIntList
return (u, v, t)
let ns = [(i,()) | i <- [1..n]]
ev = V.fromList es
es' = sortOn Down es
g = mkGraph ns es' :: Gr () Int
ds = V.fromList $ map (udijkstra g) [1..n]
f xs = f' (1:xs)
where f' [] = []
f' (x:[]) = [(x, n)]
f' (x:y:ys) = (x,y) : f' ys
calc ts = sum $ map (\(x, y) -> (ds V.! (x-1)) IM.! y) ts
q <- getInt
replicateM_ q $ do
k <- getInt
bs <- getIntList
let vs = map (\i -> ev V.! (i-1)) bs
tsum = sum $ map (\(_,_,t) -> t) vs
vps = map (f . concat) . concatMap sequence . permutations $ map (\(u,v,_) -> [[u, v], [v, u]]) vs
c = (+ tsum) . minimum $ map calc vps
print c
type Gr a b = IntMap (IntMap b, a, IntMap b)
type Node = Int
type LNode a = (Node, a)
type Edge = (Node, Node)
type LEdge a = (Node, Node, a)
type Capacity = Int
type Flow = Int
type Residual = Int
-- グラフ構築
mkGraph :: [LNode a] -> [(LEdge b)] -> Gr a b
mkGraph vs es = insEdges es . IM.fromList . map (\(v, l) -> (v, (IM.empty, l, IM.empty))) $ vs
-- 辺の加除
delEdge :: Edge -> Gr a b -> Gr a b
delEdge (v, w) g = IM.adjust (\(ins, lab, outs) -> (IM.delete v ins, lab, outs)) w $ IM.adjust (\(ins, lab, outs) -> (ins, lab, IM.delete w outs)) v $ g
insEdge :: LEdge b -> Gr a b -> Gr a b
insEdge (v, w, l) g = IM.adjust (\(ins, lab, outs) -> (IM.insert v l ins, lab, outs)) w $ IM.adjust (\(ins, lab, outs) -> (ins, lab, IM.insert w l outs)) v $ g
insEdges :: Foldable t => t (LEdge b) -> Gr a b -> Gr a b
insEdges es g = foldl' (flip insEdge) g es
-- 隣接点
suc :: (IntMap b, a, IntMap b) -> [Node]
suc (_, _, outs) = IM.keys outs
lsuc :: (IntMap b, a, IntMap b) -> [(Node, b)]
lsuc (_, _, outs) = IM.toList outs
pre :: (IntMap b, a, IntMap b) -> [Node]
pre (ins, _, _) = IM.keys ins
lpre :: (IntMap b, a, IntMap b) -> [(Node, b)]
lpre (ins, _, _) = IM.toList ins
neighbors :: (IntMap b, a, IntMap b) -> [Node]
neighbors (ins, _, outs) = IM.keys ins ++ IM.keys outs
lneighbors :: (IntMap b, a, IntMap b) -> [(Node, b)]
lneighbors (ins, _, outs) = IM.toList ins ++ IM.toList outs
-- グラフ上の辺のリストを取得
edges :: Gr a b -> [LEdge b]
edges g = concatMap (\(v, c) -> map (\(w, l) -> (v, w, l)) $ lsuc c) $ IM.toList g
-- 頂点のラベルを取得
getNodeLabel :: Gr a b -> Node -> a
getNodeLabel g n = (\(_, l, _) -> l) $ g IM.! n
-- 無向グラフ化(反対の辺を追加)
undirected :: Gr a b -> Gr a b
undirected g = foldl' addReversedEdge g (edges g)
where
addReversedEdge graph (v, w, edge) = insEdge (w, v, edge) graph
-- contextの検索
match :: Node -> Gr a b -> (Maybe (IntMap b, a, IntMap b), Gr a b)
match node g =
case IM.lookup node g of
Nothing -> (Nothing, g)
Just (p, label, s) ->
let !g1 = IM.delete node g
!g2 = clearPred g1 node s
!g3 = clearSucc g2 node p
in (Just (p, label, s), g3)
clearPred :: Gr a b -> Node -> IntMap x -> Gr a b
clearPred g v = IM.differenceWith go g
where
go :: (IntMap b, a, IntMap b) -> x -> Maybe (IntMap b, a, IntMap b)
go (ps, l, ss) _ =
let !ps' = IM.delete v ps
in Just (ps', l, ss)
clearSucc :: Gr a b -> Node -> IntMap x -> Gr a b
clearSucc g v = IM.differenceWith go g
where
go :: (IntMap b, a, IntMap b) -> x -> Maybe (IntMap b, a, IntMap b)
go (ps, l, ss) _ =
let !ss' = IM.delete v ss
in Just (ps, l, ss')
-- 始点(src)から到達可能な各頂点の深さ
level :: Gr a b -> Node -> [(Node, Int)]
level g src = leveln g (Seq.singleton (src, 0))
leveln :: Gr a b -> Seq (Node, Int) -> [(Node, Int)]
leveln _ Seq.Empty = []
leveln g _ | IM.null g = []
leveln g queue = case match v g of
(Nothing, _) -> leveln g rest
(Just c, g') -> (v, j) : leveln g' (rest Seq.>< Seq.fromList (zip (suc c) (repeat (j+1))))
where ((v, j), rest) = (Seq.index queue 0, Seq.drop 1 queue)
ulevel :: Gr a b -> Node -> [(Node, Int)]
ulevel g src = uleveln g (Seq.singleton (src, 0))
uleveln :: Gr a b -> Seq (Node, Int) -> [(Node, Int)]
uleveln _ Seq.Empty = []
uleveln g _ | IM.null g = []
uleveln g queue = case match v g of
(Nothing, _) -> uleveln g rest
(Just c, g') -> (v, j) : uleveln g' (rest Seq.>< Seq.fromList (zip (neighbors c) (repeat (j+1))))
where ((v, j), rest) = (Seq.index queue 0, Seq.drop 1 queue)
-- 深さ優先探索
-- 頂点(srcから到達可能な頂点のリスト
dfs :: Gr a b -> Node -> [Node]
dfs g src = go g [src]
where
go g [] = []
go g (v:vs) = case match v g of
(Nothing, _) -> go g vs
(Just c, g') -> v : go g' ((suc c) ++ vs)
-- Treeで返す
dfsForest :: Gr a b -> Node -> [Tree Node]
dfsForest g src = go g [src]
where
go g [] = []
go g (v:vs) = case match v g of
(Nothing, _) -> go g vs
(Just c, g') -> Node v (go g' (suc c)) : go g' vs
-- 連結判定:第1頂点から全ての頂点に到達可能か
isConnected :: Gr a b -> Bool
isConnected g = length (dfs g (fst $ head $ IM.toList g)) == IM.size g
-- 与えた頂点間(srcからsink)の任意の経路(あれば)
dfsPath :: Gr a b -> Node -> Node -> Maybe [Node]
dfsPath g src sink = fst $ go [src] g
where
go vs g | null vs || IM.null g = (Nothing, g)
go (v:vs) g = case match v g of
(Nothing, _) -> go vs g
(Just c, g') ->
if v == sink then (Just [v], g')
else case go (suc c) g' of
(Nothing, g'') -> go vs g''
(Just path, g'') -> (Just (v:path), g'')
-- 幅優先探索
-- 与えた頂点間(srcからsink)の重みなし最短経路(あれば)
bfsShortestPath :: Gr a b -> Node -> Node -> Maybe [Node]
bfsShortestPath g src sink = case paths of
[] -> Nothing
_ -> Just $ reverse $ head paths
where
paths = filter (\(w : _) -> w == sink) $ go g (Seq.singleton [src])
go g q | Seq.null q || IM.null g = []
go g q = case match v g of
(Nothing, _) -> go g rest
(Just c, g') -> p : go g' (rest Seq.>< Seq.fromList (map (:p) $ suc c))
where
(p@(v:_), rest) = (Seq.index q 0, Seq.drop 1 q)
-- ダイクストラ法
-- 始点(s)から各頂点までの重み付き最短経路長(有向)
dijkstra :: (Ord b, Num b) => Gr a b -> Node -> IntMap b
dijkstra g s = go g (H.singleton (H.Entry 0 s))
where
go g h | H.null h || IM.null g = IM.empty
go g h = case match v g of
(Nothing, g) -> go g h'
(Just c, g') -> IM.insert v d $ go g' (H.union h' (H.fromList $ map (\(w, l) -> H.Entry (l + d) w) $ lsuc c))
where Just (H.Entry d v, h') = H.uncons h
-- 始点(s)から各頂点までの重み付き最短経路長(無向)
udijkstra :: (Ord b, Num b) => Gr a b -> Node -> IntMap b
udijkstra g s = go g (H.singleton (H.Entry 0 s))
where
go g h | H.null h || IM.null g = IM.empty
go g h = case match v g of
(Nothing, g) -> go g h'
(Just c, g') -> IM.insert v d $ go g' (H.union h' (H.fromList $ map (\(w, l) -> H.Entry (l + d) w) $ (lneighbors c)))
where Just (H.Entry d v,h') = H.uncons h
-- 与えた頂点間(srcからsinkまで)の最短経路
dijkstraShortestPath :: (Ord p, Num p) => Gr a p -> Node -> Node -> [Node]
dijkstraShortestPath g src sink = reverse $ head $ filter (\(w:_)-> w==sink) $ go g (H.singleton (H.Entry 0 [src]))
where
go g h | H.null h || IM.null g = []
go g h = case match v g of
(Nothing, g) -> go g h'
(Just c, g') -> p : go g' (foldr H.union h' (map (\(w, l) -> H.singleton (H.Entry (l + d) (w:p))) $ lsuc c))
where Just (H.Entry d p@(v:_),h') = H.uncons h
-- 与えた頂点への各頂点からの経路(無向)
udijkstraAllPath :: (Ord a1, Num a1, Show a1) => Gr a2 a1 -> Node -> M.Map Node [[Node]]
udijkstraAllPath g sink = go g (M.singleton (0, sink) [[sink]])
where
go g h | M.null h || IM.null g = M.empty
go g h = case match v g of
(Nothing, g) -> go g h'
(Just c, g') -> M.insert v paths $ go g' (M.unionWith (++) h' (M.fromList $ map (\(v', w') -> ((w+w', v'), map (v':) paths)) $ lneighbors c))
where Just (((w, v), paths), h') = M.minViewWithKey h
app/Main.hs:2: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()
|
2 | import Control.Monad.ST
| ^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:3:1: warning: [-Wunused-imports]
The import of ‘Control.Monad.Primitive’ is redundant
except perhaps to import instances from ‘Control.Monad.Primitive’
To import instances alone, use: import Control.Monad.Primitive()
|
3 | import Control.Monad.Primitive
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:7: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()
|
7 | import Data.Char
| ^^^^^^^^^^^^^^^^
app/Main.hs:9:1: warning: [-Wunused-imports]
The import of ‘Data.Ix’ is redundant
except perhaps to import instances from ‘Data.Ix’
To import instances alone, use: import Data.Ix()
|
9 | import Data.Ix
| ^^^^^^^^^^^^^^
app/Main.hs:10:1: warning: [-Wunused-imports]
The import of ‘Data.Bool’ is redundant
except perhaps to import instances from ‘Data.Bool’
To import instances alone, use: import Data.Bool()
|
10 | import Data.Bool
| ^^^^^^^^^^^^^^^^
app/Main.hs:11:1: warning: [-Wunused-imports]
The import of ‘Data.Vector.Unboxed.Base’ is redundant
except perhaps to import instances from ‘Data.Vector.Unboxed.Base’
To import instances alone, use: import Data.Vector.Unboxed.Base()
|
11 | import Data.Vector.Unboxed.Base
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:12:1: warning: [-Wunused-imports]
The qualified import of ‘Data.Vector.Unboxed’ is redundant
except perhaps to import instances from ‘Data.Vector.Unboxed’
To import instances alone, use: import Data.Vector.Unboxed()
|
12 | import qualified Data.Vector.Unboxed as VU
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:13:1: warning: [-Wunused-imports]
The qualified import of ‘Data.Vector.Unboxed.Mutable’ is redundant
except perhaps to import instances from ‘Data.Vector.Unboxed.Mutable’
To import instances alone, use: import Data.Vector.Unboxed.Mutable()
|
13 | import qualified Data.Vector.Unboxed.Mutable as VUM
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:15:1: warning: [-Wunused-imports]
The qualified import of ‘Data.Vector.Mutable’ is redundant
except perhaps to import instances from ‘Data.Vector.Mutable’
To import instances alone, use: import Data.Vector.Mutable()
|
15 | import qualified Data.Vector.Mutable as VM
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:16:1: warning: [-Wunused-imports]
The import of ‘Data.Array’ is redundant
except perhaps to import instances from ‘Data.Array’
To import instances alone, use: import Data.Array()
|
16 | import Data.Array
| ^^^^^^^^^^^^^^^^^
app/Main.hs:17:1: warning: [-Wunused-imports]
The import of ‘Data.Array.ST’ is redundant
except perhaps to import instances from ‘Data.Array.ST’
To import instances alone, use: import Data.Array.ST()
|
17 | import Data.Array.ST
| ^^^^^^^^^^^^^^^^^^^^
app/Main.hs:20: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()
|
20 | import qualified Data.Set as Set
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:27:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
readInt :: BS.ByteString -> Int
|
27 | readInt = fst . fromJust . BS.readInt
| ^^^^^^^
app/Main.hs:28:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
readIntList :: BS.ByteString -> [Int]
|
28 | readIntList = map readInt . BS.words
| ^^^^^^^^^^^
app/Main.hs:29:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: getInt :: IO Int
|
29 | getInt = readInt <$> BS.getLine
| ^^^^^^
app/Main.hs:30:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: getIntList :: IO [Int]
|
30 | getIntList = readIntList <$> BS.getLine
| ^^^^^^^^^^
app/Main.hs:32:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature:
putStrList :: Show a => [a] -> IO ()
|
32 | putStrList xs = putStrLn . unwords $ map show xs
| ^^^^^^^^^^
app/Main.hs:32:1: warning: [-Wunused-top-binds]
Defined but not used: ‘putStrList’
|
32 | putStrList xs = putStrLn . unwords $ map show xs
| ^^^^^^^^^^
app/Main.hs:34:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: main :: IO ()
|
34 | main = do
| ^^^^
app/Main.hs:54:9: warning: [-Wunused-matches]
Defined but not used: ‘k’
|
54 | k <- getInt
| ^
app/Main.hs:67:1: warning: [-Wunused-top-binds]
Defined but not used: type constructor or class ‘Capacity’
|
67 | type Capacity = Int
| ^^^^^^^^^^^^^^^^^^^
app/Main.hs:68:1: warning: [-Wunused-top-binds]
Defined but not used: type constructor or class ‘Flow’
|
68 | type Flow = Int
| ^^^^^^^^^^^^^^^
app/Main.hs:69:1: warning: [-Wunused-top-binds]
Defined but not used: type constructor or class ‘Residual’
|
69 | type Residual = Int
| ^^^^^^^^^^^^^^^^^^^
app/Main.hs:78:1: warning: [-Wunused-top-binds]
Defined but not used: ‘delEdge’
|
78 | delEdge (v, w) g = IM.adjust (\(ins, lab, outs) -> (IM.delete v ins, lab, outs)) w $ IM.adjust (\(ins, lab, outs) -> (ins, lab, IM.delete w outs)) v $ g
| ^^^^^^^
app/Main.hs:88:1: warning: [-Wunused-top-binds]
Defined but not used: ‘suc’
|
88 | suc (_, _, outs) = IM.keys outs
| ^^^
app/Main.hs:91:1: warning: [-Wunused-top-binds]
Defined but not used: ‘lsuc’
|
91 | lsuc (_, _, outs) = IM.toList outs
| ^^^^
app/Main.hs:94:1: warning: [-Wunused-top-binds]
Defined but not used: ‘pre’
|
94 | pre (ins, _, _) = IM.keys ins
| ^^^
app/Main.hs:97:1: warning: [-Wunused-top-binds]
Defined but not used: ‘lpre’
|
97 | lpre (ins, _, _) = IM.toList ins
| ^^^^
app/Main.hs:100:1: warning: [-Wunused-top-binds]
Defined but not used: ‘neighbors’
|
100 | neighbors (ins, _, outs) = IM.keys ins ++ IM.keys outs
| ^^^^^^^^^
app/Main.hs:107:1: warning: [-Wunused-top-binds]
Defined but not used: ‘edges’
|
107 | edges g = concatMap (\(v, c) -> map (\(w, l) -> (v, w, l)) $ lsuc c) $ IM.toList g
| ^^^^^
app/Main.hs:111:1: warning: [-Wunused-top-binds]
Defined but not used: ‘getNodeLabel’
|
111 | getNodeLabel g n = (\(_, l, _) -> l) $ g IM.! n
| ^^^^^^^^^^^^
app/Main.hs:115:1: warning: [-Wunused-top-binds]
Defined but not used: ‘undirected’
|
115 | undirected g = foldl' addReversedEdge g (edges g)
| ^^^^^^^^^^
app/Main.hs:148:1: warning: [-Wunused-top-binds]
Defined but not used: ‘level’
|
148 | level g src = leveln g (Seq.singleton (src, 0))
| ^^^^^
app/Main.hs:151:1: warning: [-Wunused-top-binds]
Defined but not used: ‘leveln’
|
151 | leveln _ Seq.Empty = []
| ^^^^^^
app/Main.hs:159:1: warning: [-Wunused-top-binds]
Defined but not used: ‘ulevel’
|
159 | ulevel g src = uleveln g (Seq.singleton (src, 0))
| ^^^^^^
app/Main.hs:162:1: warning: [-Wunused-top-binds]
Defined but not used: ‘uleveln’
|
162 | uleveln _ Seq.Empty = []
| ^^^^^^^
app/Main.hs:172:1: warning: [-Wunused-top-binds]
Defined but not used: ‘dfs’
|
172 | dfs g src = go g [src]
| ^^^
app/Main.hs:174:8: warning: [-Wunused-matches]
Defined but not used: ‘g’
|
174 | go g [] = []
| ^
app/Main.hs:174:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:172:5
|
174 | go g [] = []
| ^
app/Main.hs:175:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:172:5
|
175 | go g (v:vs) = case match v g of
| ^
app/Main.hs:181:1: warning: [-Wunused-top-binds]
Defined but not used: ‘dfsForest’
|
181 | dfsForest g src = go g [src]
| ^^^^^^^^^
app/Main.hs:183:8: warning: [-Wunused-matches]
Defined but not used: ‘g’
|
183 | go g [] = []
| ^
app/Main.hs:183:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:181:11
|
183 | go g [] = []
| ^
app/Main.hs:184:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:181:11
|
184 | go g (v:vs) = case match v g of
| ^
app/Main.hs:190:1: warning: [-Wunused-top-binds]
Defined but not used: ‘isConnected’
|
190 | isConnected g = length (dfs g (fst $ head $ IM.toList g)) == IM.size g
| ^^^^^^^^^^^
app/Main.hs:194:1: warning: [-Wunused-top-binds]
Defined but not used: ‘dfsPath’
|
194 | dfsPath g src sink = fst $ go [src] g
| ^^^^^^^
app/Main.hs:196:5: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for ‘go’:
Patterns of type ‘[Node]’,
‘IntMap (IntMap b, a, IntMap b)’ not matched:
[] _
|
196 | go vs g | null vs || IM.null g = (Nothing, g)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
app/Main.hs:196:11: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:194:9
|
196 | go vs g | null vs || IM.null g = (Nothing, g)
| ^
app/Main.hs:197:15: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:194:9
|
197 | go (v:vs) g = case match v g of
| ^
app/Main.hs:208:1: warning: [-Wunused-top-binds]
Defined but not used: ‘bfsShortestPath’
|
208 | bfsShortestPath g src sink = case paths of
| ^^^^^^^^^^^^^^^
app/Main.hs:212:21: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a lambda abstraction: Patterns of type ‘[Node]’ not matched: []
|
212 | paths = filter (\(w : _) -> w == sink) $ go g (Seq.singleton [src])
| ^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:213:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:208:17
|
213 | go g q | Seq.null q || IM.null g = []
| ^
app/Main.hs:214:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:208:17
|
214 | go g q = case match v g of
| ^
app/Main.hs:218:9: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding:
Patterns of type ‘([Node], Seq [Node])’ not matched: ([], _)
|
218 | (p@(v:_), rest) = (Seq.index q 0, Seq.drop 1 q)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:223:1: warning: [-Wunused-top-binds]
Defined but not used: ‘dijkstra’
|
223 | dijkstra g s = go g (H.singleton (H.Entry 0 s))
| ^^^^^^^^
app/Main.hs:225:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:223:10
|
225 | go g h | H.null h || IM.null g = IM.empty
| ^
app/Main.hs:226:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:223:10
|
226 | go g h = case match v g of
| ^
app/Main.hs:227:17: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:226:8
|
227 | (Nothing, g) -> go g h'
| ^
app/Main.hs:229:13: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding:
Patterns of type ‘Maybe
(H.Entry a Node, H.Heap (H.Entry a Node))’ not matched:
Nothing
|
229 | where Just (H.Entry d v, h') = H.uncons h
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:235:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:233:11
|
235 | go g h | H.null h || IM.null g = IM.empty
| ^
app/Main.hs:236:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:233:11
|
236 | go g h = case match v g of
| ^
app/Main.hs:237:17: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:236:8
|
237 | (Nothing, g) -> go g h'
| ^
app/Main.hs:239:13: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding:
Patterns of type ‘Maybe
(H.Entry a Node, H.Heap (H.Entry a Node))’ not matched:
Nothing
|
239 | where Just (H.Entry d v,h') = H.uncons h
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:243:1: warning: [-Wunused-top-binds]
Defined but not used: ‘dijkstraShortestPath’
|
243 | dijkstraShortestPath g src sink = reverse $ head $ filter (\(w:_)-> w==sink) $ go g (H.singleton (H.Entry 0 [src]))
| ^^^^^^^^^^^^^^^^^^^^
app/Main.hs:243:60: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a lambda abstraction: Patterns of type ‘[Node]’ not matched: []
|
243 | dijkstraShortestPath g src sink = reverse $ head $ filter (\(w:_)-> w==sink) $ go g (H.singleton (H.Entry 0 [src]))
| ^^^^^^^^^^^^^^^^
app/Main.hs:245:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:243:22
|
245 | go g h | H.null h || IM.null g = []
| ^
app/Main.hs:246:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:243:22
|
246 | go g h = case match v g of
| ^
app/Main.hs:247:17: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:246:8
|
247 | (Nothing, g) -> go g h'
| ^
app/Main.hs:249:13: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding:
Patterns of type ‘Maybe
(H.Entry p [Node], H.Heap (H.Entry p [Node]))’ not matched:
Nothing
Just ((H.Entry _ []), _)
|
249 | where Just (H.Entry d p@(v:_),h') = H.uncons h
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/Main.hs:253:1: warning: [-Wunused-top-binds]
Defined but not used: ‘udijkstraAllPath’
|
253 | udijkstraAllPath g sink = go g (M.singleton (0, sink) [[sink]])
| ^^^^^^^^^^^^^^^^
app/Main.hs:255:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:253:18
|
255 | go g h | M.null h || IM.null g = M.empty
| ^
app/Main.hs:256:8: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:253:18
|
256 | go g h = case match v g of
| ^
app/Main.hs:257:17: warning: [-Wname-shadowing]
This binding for ‘g’ shadows the existing binding
bound at app/Main.hs:256:8
|
257 | (Nothing, g) -> go g h'
| ^
app/Main.hs:259:13: warning: [-Wincomplete-uni-patterns]
Pattern match(es) are non-exhaustive
In a pattern binding:
Patterns of type ‘Maybe
(((a, Node), [[Node]]), M.Map (a, Node) [[Node]])’ not matched:
Nothing
|
259 | where Just (((w, v), paths), h') = M.minViewWithKey h
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^