1.
Hdu4619:http://acm.hdu.edu.cn/showproblem.php?pid=4619
某次多校的题目。
最大独立集 = 顶点数 - 最大匹配数
可以确定每两个合为一体的话可以看作一二分图。 然后这个最大独立集。
2.
POJ1422:http://poj.org/problem?id=1422
有向无环图化为二分图。 拆点连边。
求最小路径覆盖。 亦 = 顶点数 - 最大匹配数。
3.
POJ3020:http://poj.org/problem?id=3020
反证法可证图为二分图。 二分图好构建。 划分关系不明确。 比如对于X,Y不确定X,Y分别属于哪部半图。
最小路径覆盖。
现在可以明白最小路径覆盖针对有向图以及二分图的路径关系 = 顶点数 - 最大匹配数呗~ 这地方的理解结合非路径终点理解就很容易了
自己写的时候循环弄错。
for(i<=sum) 其实照自己的构图方式应该是 for(i<=n*m)
附个代码:
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define clr(x,y) memset(x,y,sizeof(x))
const int maxn = 500; //<strong><strong>二分</strong></strong>图左、右两边数目
int n, m, sum;
int match[maxn], g[maxn][maxn], adj[maxn][maxn];
bool used[maxn];
bool find(int u)
{
for(int i = 1; i <= n*m; i++)
{
if(g[u][i] && !used[i])
{
used[i] = true;
if(match[i] == -1 || find(match[i]))
…………………………………………………………………………<p style="COLOR: red; FONT-SIZE: 16px"><strong>来自:<a target=_blank href="http://www.verydemo.com/demo_c116_i107017.html" target="_blank">http://www.verydemo.com/demo_c116_i107017.html</a></strong></p>