hdu 1054 Strategic Game 最小点覆盖
来源:互联网 发布:太极越狱mac 编辑:程序博客网 时间:2024/05/17 05:03
建双向边,然后最大匹配/2。另外邻接矩阵会T..
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int N = 1505;struct node{int to, nxt;}e[N*N];int head[N];int cnt;int n;int link[N], vis[N];void add( int u, int v ){e[cnt].to = v;e[cnt].nxt = head[u];head[u] = cnt++;e[cnt].to = u;e[cnt].nxt = head[v];head[v] = cnt++;}int dfs( int u ){for( int i = head[u]; ~i; i = e[i].nxt ){int to = e[i].to;if( !vis[to] ){vis[to] = 1;if( link[to] == -1 || dfs(link[to]) ){link[to] = u;return 1;}}}return 0;}int main(){while(~scanf("%d", &n)){int src, m;cnt = 0;memset(head, -1, sizeof(head));for( int i = 1; i <= n; i++ ){int to;scanf("%d:(%d)", &src, &m);src++;while(m--){scanf("%d", &to);to++;add(src, to);}}int ans = 0;memset(link, -1, sizeof(link));for( int i = 1; i <= n; i++){memset(vis, 0, sizeof(vis));ans += dfs(i);}printf("%d\n", ans/2);}return 0;}
0 0
- HDU--1054--Strategic Game【最小点覆盖】
- hdu 1054 Strategic Game 最小点覆盖
- hdu 1054 Strategic Game(最小点覆盖)
- hdu 1054 Strategic Game 最小点覆盖集
- HDU 1054 Strategic Game 二分图最小点覆盖
- hdu 1054 Strategic Game (最小顶点覆盖)
- HDU 1054 Strategic Game 最小顶点覆盖
- HDU 1054 Strategic Game (最小顶点覆盖)
- hdu 1054 Strategic Game【最小顶点覆盖】
- HDU 1054 Strategic Game 最小顶点覆盖
- HDU 1054 Strategic Game 最小顶点覆盖
- hdu 1054 Strategic Game 点覆盖数
- hdu 1054 Strategic Game(最小点覆盖集转换成双向二分图)
- HDU 1054Strategic Game(一般图匹配之最小点覆盖)
- hdu 1054 Strategic Game 树形dp基础题,树的最小点覆盖
- hdu 1054 Strategic Game 二分图的匹配,最小点覆盖数
- HDU 1054 Strategic Game(二分图最小点覆盖 或者 树形DP)
- hdu 1054 Strategic Game(模板) 最大二分匹配,最小点覆盖 匈牙利算法
- python 过滤四字节字符 表情字符
- Linux makefile 教程 非常详细,且易懂
- ImageView
- Myeclipse 10 Maven 构建 Java Web 项目
- 小兔的棋盘
- hdu 1054 Strategic Game 最小点覆盖
- 基于Arm 的linux 的启动分析
- 关于手机和各种pad的定位
- EOJ2562
- poj 2366 Sacrament of the sum 尺取法的灵活运用
- 数据挖掘过程模型研究
- 晶振两端串联和并联电阻的租用
- hadoop学习5-HDFS API学习
- DICOM医学图像处理:DIMSE消息发送与接收“大同小异”之DCMTK fo-dicom mDCM