SRM 640 Div.1 550 - MaximumBipartiteMatchingProblem
Solution:
A very mathematical problem I guess, we will get to optimise a quadratic function. Firstly, take ans vertices from both n1 and n2, and match them like this:
ans pairs of vertices: o o o o o -> upper-end | | | | | o o o o o -> lower-end
That means we have (n1-ans) unmatched vertices from the first set F, and (n2-ans) unmatched vertices from the second set S. We cannot match any of these unmatched vertices amongst themselves, because it will immediately increase the number of bipartite matching. So we can only match them with those ans paired vertices