Count vertex subsets of a weighted bipartite graph whose total weight is at least t and that some matching covers completely.
Hard8Dynamic programmingBit manipulationCombinatoricsGraphNo attempts yetTime limit3sMemory limit512 MBIn a bipartite graph the vertices are split into two disjoint sets A and B, and every edge joins one vertex of A with one vertex of B. A matching M is a set of edges in which no two edges share a vertex. A matching M blankets a set of vertices V when every vertex of V is an endpoint of some edge of M.
You are given a bipartite graph in which every vertex carries a positive integer weight. The weight of a set of vertices is the sum of the weights of its vertices.
You are also given an integer threshold t. Count the sets of vertices V whose weight is at least t and which are blanketed by at least one matching. Here V is a subset of A∪B, and two different subsets count separately.
The first line contains the number of vertices n in A and the number of vertices m in B, separated by a space (1≤n,m≤20). The vertices of A are a1,a2,…,an and the vertices of B are b1,b2,…,bm.
Each of the next n lines contains m characters that describe the edges. The j-th character of the i-th line is 1 if there is an edge between ai and bj, and 0 otherwise.
The next line contains n integers v1,v2,…,vn (1≤vk≤10000000), where vk is the weight of ak. The line after that contains m integers w1,w2,…,wm (1≤wk≤10000000), where wk is the weight of bk.
The last line contains the integer t (1≤t≤400000000).
Print on one line the number of vertex sets whose weight is at least t and that are blanketed by some matching.
In the first example the subset {a1,a2,b2,b3} is blanketed by the matching {(a1,b2),(a2,b3)} and has weight 21. The subsets {a3,b2,b3} and {a2,a3,b2,b3} are both blanketed by the matching {(a2,b3),(a3,b2)} and have weights 21 and 23. Every other subset either weighs less than 21 or is blanketed by no matching. For instance {a2,a3,b1,b3} has weight 26, but no matching blankets it, so it is not counted.