http://acm.hdu.edu.cn/showproblem.php?pid=1068
因为没有指定性别,所以要拆点,把i拆分i和i’ 那么U=V-M (M是最大匹配,U最大独立集,V是顶点数)
2U=2V-2M 所以 U=n-M'/2. (没怎么看明白) 但是不这样会wa.
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue>
#pragma comment(linker, "/STACK:102400000,102400000")
#define CL(arr, val) memset(arr, val, sizeof(arr)) #define ll long long
#define inf 0x7f7f7f7f
#define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0) #define L(x) (x) << 1
#define R(x) (x) << 1 | 1
#define MID(l, r) (l + r) >> 1
#define Min(x, y) (x) < (y) ? (x) : (y)
#define Max(x, y) (x) < (y) ? (y) : (x)
#define E(x) (1 << (x))
#define iabs(x) (x) < 0 ? -(x) : (x)
#define OUT(x) printf("%I64d\n", x)
#define lowbit(x) (x)&(-x)
#define Read() freopen("a.txt", "r", stdin)
#define Write() freopen("b.txt", "w", stdout);
#define maxn 1000000000
#define N 510
#define mod 1000000000
using namespace std; vector<int>G[N];
int link[N];
bool vis[N]; bool dfs(int u)
{
for(int i=;i<G[u].size();i++)
{
int v=G[u][i];
if(!vis[v])
{
vis[v]=true;
if(link[v]==-||dfs(link[v]))
{
link[v]=u;
return true;
}
}
}
return false;
}
int main()
{
//Read();
int n,a,b,c;
while(~scanf("%d",&n))
{
for(int i=;i<n;i++) G[i].clear();
for(int i=;i<n;i++)
{
scanf("%d: (%d)",&a,&b);
// printf("%d %d\n",a,b);
for(int i=;i<b;i++)
{
scanf("%d",&c);
G[a].push_back(c);
}
}
int ans=;
memset(link,-,sizeof(link));
for(int i=;i<n;i++)
{
memset(vis,,sizeof(vis));
if(dfs(i)) ans++;
}
printf("%d\n",n-ans/);
}
return ;
}