思路
这是个板子题,二分图的最小点覆盖
#include <iostream>
using namespace std;
int e[500][500], n, m, match[500], ans, book[500], cow[500];
int dfs(int u){
for (int i = 1; i <= m; i++){
if (e[u][i] == 1 && book[i] == 0){
book[i] = 1;
if (match[i] == 0 || dfs(match[i]) == 1){
match[i] = u;
return 1;
}
}
}
return 0;
}
int main(){
int t, x, p;
cin >> n >> m >> p;
for (int i = 1; i <= p; i++){
cin >> t >> x;
e[t][x] = 1;
}
for (int i = 1; i <= n; i++){
memset(book, 0, sizeof(book));
if (dfs(i) == 1) ans ++;
}
cout << ans << endl;
return 0;
}