标签:输入数据 col 决定 pat class title bottom size pac
http://acm.hdu.edu.cn/showproblem.php?pid=2063
代码:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
int K, M, N;
int mp[1010][1010];
int vis[maxn], match[maxn];
bool path(int u) {
for(int v = 1; v <= N; v ++) {
if(mp[u][v] && !vis[v]) {
vis[v] = 1;
if(match[v] == -1 || path(match[v])) {
match[v] = u;
return true;
}
}
}
return false;
}
int main() {
while(~scanf("%d", &K)) {
if(!K) break;
memset(match, -1, sizeof(match));
memset(mp, 0, sizeof(mp));
scanf("%d%d", &M, &N);
while(K --) {
int x, y;
scanf("%d%d", &x, &y);
mp[x][y] = 1;
}
int cnt = 0;
for(int i = 1; i <= M; i ++) {
memset(vis, 0, sizeof(vis));
if(path(i))
cnt ++;
}
printf("%d\n", cnt);
}
return 0;
}
匈牙利算法求最大匹配数
杭州今天 32° 认真的么
标签:输入数据 col 决定 pat class title bottom size pac
原文地址:https://www.cnblogs.com/zlrrrr/p/10669826.html