BZOJ2140: Stable Marriage — Solution
Main Idea
For each marriage, add a directed edge from the man to the woman; for each lover relationship, add a directed edge from the woman to the man. Then just count the strongly connected components of size one.