poj 1274 -- The Perfect Stall (二分图)
来源:互联网 发布:小雀斑银行知乎 编辑:程序博客网 时间:2024/04/28 01:17
小小纪念
# include <cstdio># include <iostream># include <set># include <map># include <vector># include <list># include <queue># include <stack># include <cstring># include <string># include <cstdlib># include <cmath># include <algorithm># define ll long longusing namespace std ;struct Edge { int v , next ;} g [ 50000 ] ; ;int head [ 210 ] , cnt ;bool vis [ 210 ] ;int n , m , cx [ 210 ] , cy [ 210 ] ;void addedge ( int u , int v ){ g [ cnt ] . v = v ; g [ cnt ] . next = head [ u ] ; head [ u ] = cnt ++ ;}bool dfs ( int u ){ for ( int i = head [ u ] ; ~ i ; i = g [ i ] . next ) { int v = g [ i ] . v ; if ( ! vis [ v ] ) { vis [ v ] = 1 ; if ( cy [ v ] == -1 || dfs ( cy [ v ] ) ) { cx [ u ] = v ; cy [ v ] = u ; return true ; } } } return false ;}int fuck ( ){ int ans = 0 ; memset ( cx , -1 , sizeof ( cx ) ) ; memset ( cy , -1 , sizeof ( cy ) ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( cx [ i ] == -1 ) { memset ( vis , 0 , sizeof ( vis ) ) ; ans += dfs ( i ) ; } } return ans ;}int main ( ){ cin . sync_with_stdio ( false ) ; while ( cin >> n >> m ) { cnt = 0 ; memset ( head , -1 , sizeof ( head ) ) ; for ( int i = 1 ; i <= n ; i ++ ) { int num ; cin >> num ; while ( num -- ) { int v ; cin >> v ; addedge ( i , v ) ; } } cout << fuck ( ) << endl ; }}
- poj 1274 -- The Perfect Stall (二分图)
- 【POJ】1274 The Perfect Stall 二分匹配
- Poj 1274 The Perfect Stall【二分匹配】
- POJ 1274 The Perfect Stall 二分图最大匹配
- 二分图匹配(简单题)POJ 1274 The Perfect Stall
- 二分图最大基数匹配 POJ 1274 The Perfect Stall
- POJ 1274 The Perfect Stall(二分图最大匹配)
- 【二分图+最大匹配】北大 poj 1274 The Perfect Stall
- POJ 1274 The Perfect Stall 【二分图匹配】
- 二分图学习小记 Poj 1274 The Perfect Stall
- poj 1274 The Perfect Stall (二分图匹配)
- Poj 1274 The Perfect Stall[二分图最大匹配]
- POJ 1274The Perfect Stall(二分图最大匹配)
- POJ 1274 The Perfect Stall 二分图最大匹配
- POJ 1274 The Perfect Stall(二分图最大匹配)
- The Perfect Stall - POJ 1274 二分图匹配
- POJ 1274 The Perfect Stall(二分图匹配)
- POJ 1274-The Perfect Stall(二分图_最大匹配)
- HTTP协议详解
- 【雨水季节如何养生】
- 如何使用gcc编译器?
- 【Reading】2013-05, 06, 07, 08
- 5.19数据库
- poj 1274 -- The Perfect Stall (二分图)
- 九度OJ 1021 统计字符
- 如何创建ORACLE大文件表空间
- 慎用为初始化变量
- win7,ubuntu双系统——重装win7后如何恢复ubuntu引导
- gcc/g++编译
- Web.xml的配置及加载
- 十全大补:CxImage图像处理类库
- 《Flex4 实战》读书笔记