poj Girls and Boys 二分图匹配
来源:互联网 发布:打字软件免费下载 编辑:程序博客网 时间:2024/05/16 12:03
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;int n,p[1024],g[1024][1024],cx[1024],cy[1024],my[1024];int dfs(int u){ int v; for(v=0;v<n;v++) { if(g[u][v]==1&&my[v]==0) { my[v]=1; if(cy[v]==-1||dfs(cy[v])) { cx[u]=v; cy[v]=u; return 1; } } } return 0;}int MaxMatch(){ int i,res=0; memset(cx,0xff,sizeof(cx)); memset(cy,0xff,sizeof(cy)); for(i=0;i<n;i++) { if(cx[i]==-1) { memset(my,0,sizeof(my)); res+=dfs(i); } } return res;}int main(){ int i,j,t,m; while(~scanf("%d",&n)) { memset(p,0xff,sizeof(p)); memset(g,0,sizeof(g)); for(i=0;i<n;i++) { scanf("%d: (%d)",&t,&m); if(m==0) continue; for(j=0;j<m;j++) { scanf("%d",&t); g[t][i]=g[i][t]=1; } } int ans=MaxMatch(); if(ans%2==1) ans++; printf("%d\n",n-ans/2); } return 0;}
0 0
- poj Girls and Boys 二分图匹配
- POJ 1466 - Girls and Boys(二分图匹配)
- poj 1466 Girls and Boys(二分图最大匹配)
- Girls and Boys(二分图匹配)
- Girls and Boys (二分匹配)
- POJ 1466 Girls and Boys 二分图
- POJ 1466 Girls and Boys 最大独立集 二分图匹配
- HDU-1068 &&POJ-1466 Girls and Boys 简单二分图匹配
- POJ 1466 Girls and Boys(二分图匹配+拆点+最大独立集)
- Girls and Boys(二分图)
- hdu 1068 Girls and Boys(二分图匹配)
- hdu 1068 Girls and Boys (二分图匹配)
- HDU 1068Girls and Boys(二分图最大匹配)
- hdu 1068 Girls and Boys(水题,二分图匹配)
- HDU 1068 Girls and Boys(二分图最大匹配)
- poj1466 Girls and Boys (最大独立集 二分图匹配)
- hdu 1068 Girls and Boys 二分图的最大匹配
- hdoj 1068 Girls and Boys 【匈牙利算法&&二分图匹配】
- POJ1556The Doors【判断线段相交+dijkstra】
- UVa 524:Prime Ring Problem(回溯)
- 【转】第一章 Shiro简介
- "Python"学习笔记(三)(数据类型)
- cinのpeek putback
- poj Girls and Boys 二分图匹配
- Http学习笔记
- centos 虚拟机模拟联网的MAC地址问题
- poj 1007 DNA Sorting 【对逆序数进行sort排序】
- VB+DX游戏编程教程 第三话:多变的矩阵
- 中文编码方案
- 进程process与线程thread总结
- phalcon 编译问题
- php实现ocr文字识别