最小顶点覆盖:用最少的点,让每条边都至少和其中一个点关联;
。。。以为自己很聪明。。用边连边。。。最后还是点连点 哎。。。。
hc 写的 匈牙利足够/
#include#include #include #include #include #include #include #define mem(a, b) memset(a, b, sizeof(a))using namespace std;const int maxn = 10010, INF = 0x7fffffff;int dx[maxn], dy[maxn], cx[maxn], cy[maxn], used[maxn];int nx, ny, dis, n;vector G[maxn];int bfs(){ queue Q; dis = INF; mem(dx, -1); mem(dy, -1); for(int i=0; i<=nx; i++) { if(cx[i] == -1) { Q.push(i); dx[i] = 0; } } while(!Q.empty()) { int u = Q.front(); Q.pop(); if(dx[u] > dis) break; for(int v=0; v > n) { for(int i=0; i