标签:style blog color io os for sp div on
#include <iostream> #include <memory.h> #include <cstdio> using namespace std; int c; const int maxn=502; int visit[maxn],map[maxn][maxn],link[maxn]; bool DFS(int a) { for(int i=0;i<c;i++) { if(!visit[i] && map[a][i]) { visit[i]=1; if(link[i]==-1 || DFS(link[i])) { link[i]=a; return true; } } } return false; } int main() { // freopen("in.txt","r",stdin); int x,y,tmp; while(cin >> c) { memset(map,0,sizeof(map)); memset(link,-1,sizeof(link)); for(int i=0;i<c;i++) { scanf("%d: (%d)",&x,&y); for(int j=0;j<y;j++) { scanf("%d",&tmp); map[i][tmp]=1; } } int sum=0; for(int i=0;i<c;i++) { memset(visit,0,sizeof(visit)); if(DFS(i))sum++; } cout << c-sum/2 <<endl; } return 0; }
标签:style blog color io os for sp div on
原文地址:http://www.cnblogs.com/balfish/p/4015224.html