Optimal Matching

Revision en2, by saccha_hindu_bhakt, 2020-05-21 15:16:27

We have a matrix of n*n. Entries are only 0 or 1. Now we need to come up with some matching (vertical or horizontal) for 1's such that 2 1's can be matched. No 0's can be converted to 1 or vice versa. Also, a 1 can be matched to only a single 1, in simple words we cannot a single 1 to two or more 1.

We need to print Yes if there's a matching exist such that all 1's are paired or No if not. If Yes, then print all the matching as well. Print any solution if there are multiple matching for a case.

Example-

Input 4 0011 1110 1110 1111

Output Yes (1,3)(1,4) (2,1)(3,1) (2,2)(3,2) (2,3)(3,3) (4,1)(4,2) (4,3)(4,4)

For n<=200. This can be done by Maximum Bipartite Matching. But can't really do it.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English saccha_hindu_bhakt 2020-05-21 20:27:39 22 Tiny change: 'My bad' -> 'ABC'
en4 English saccha_hindu_bhakt 2020-05-21 20:25:55 774
en3 English saccha_hindu_bhakt 2020-05-21 15:17:08 20
en2 English saccha_hindu_bhakt 2020-05-21 15:16:27 6
en1 English saccha_hindu_bhakt 2020-05-21 15:15:21 746 Initial revision (published)