i'm looking for a well written, bug-free and fast code for the bipartite matching algorithm. can anyone share your code please?
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Name |
---|
Not my code but I think this is pretty good: http://zobayer.blogspot.com/2010/05/maximum-matching.html
thanks.
I want to share my version of bipartite matching, in the hope that, if it is wrong on certain test cases, someone would notice. It is not conventional, in the sense that the "Match" function has one loop instead of two. I have never noticed any notable difference, and the code is pretty short and encapsulated.
https://github.com/bicsi/code_snippets/blob/master/bipartite_match.cpp
Your implementation is O(VE) (and it is called Kuhn matching if I am not mistaken)
Do you have AC on these problems with this code?
http://www.spoj.com/problems/MATCHING/
http://codeforces.net/contest/722/problem/D
The last one it is intended to be greedy, but I got TLE with Kuhn and AC with Hopcroft-Karp
Both problems got accepted, without any substantial modifications to the algorithm. Link to the CF problem: http://codeforces.net/contest/722/submission/22865806
However, it seems that having the two "parts" of the bipartite graph swapped, I was getting TLE. Probably because at the same number of iterations, I was doing O(n * log(n)) work going through the bigger part, rather than O(n).
EDIT: It seems that a simple test comparing the two versions on the number of iteration of the outer loop on random test cases would easily prove / disprove the algorithm. I am, however, too lazy to do that right now :).