Bipartite Barricade
Time limit2.5sMemory limit1024 MB
Count the vertex subsets of a bipartite graph whose total weight is at least t and that some matching fully covers, with every subset vertex matched.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Dynamic programming, Graph
- Solved
- No attempts yet
Problem
In a bipartite graph, the vertices can be split into two disjoint sets and so that every edge connects a vertex in with a vertex in . A matching is a set of edges where no two edges share a vertex. A matching barricades a vertex set if every vertex in is an endpoint of at least one edge in .
Each vertex has an integer weight. The weight of a vertex set is the sum of the weights of its vertices.
Given an integer , count the vertex sets whose weight is at least and which are barricaded by at least one matching.
Input
The first line contains natural numbers and (), the number of vertices in sets and . The vertices are denoted and .
Each of the next lines contains a string of characters. The -th character of the -th line is '1' if there is an edge between and , and '0' otherwise.
The next line contains the weights of ().
The next line contains the weights of ().
The last line contains the natural number ().
Output
Print the number of vertex sets with weight at least that are barricaded by at least one matching.
Hint
Explanation of the first sample. The set is barricaded by the matching and has weight 21. The sets and are barricaded by the matching , with weights 21 and 23. All other sets either have weight below 21 or are not barricaded by any matching. For example, the set has weight 26, but no matching barricades it.