杭电 hdu 1498 50 years, 50 colors (二分图,最大匹配)
来源:互联网 发布:java 日志记录 编辑:程序博客网 时间:2024/05/17 22:26
/* THE PROGRAM IS MADE BY PYY *//*----------------------------------------------------------------------------//Copyright (c) 2011 panyanyany All rights reserved.URL : http://acm.hdu.edu.cn/showproblem.php?pid=1498Name : 1498 50 years, 50 colorsDate : Friday, August 26, 2011Time Stage : 1 hoursResult:44994742011-08-26 21:00:07Accepted149815MS272K1856 BC++pyyTest Data:Review://----------------------------------------------------------------------------*/#include <stdio.h>#include <string.h>#include <stdlib.h>#define max(a, b) (((a) > (b)) ? (a) : (b))#define min(a, b) (((a) < (b)) ? (a) : (b))#define FALSE0#define TRUE1#define infinity 0x0f0f0f0f#define minus_inf 0x80808080#define MAXSIZE109int n, k ;int cover[MAXSIZE], link[MAXSIZE], count[MAXSIZE], record[MAXSIZE] ;int map[MAXSIZE][MAXSIZE] ;int find (int cur, int color){int i ;for (i = 1 ; i <= n ; ++i)if (map[cur][i] == color && cover[i] == 0)// 颜色要一致,且没有覆盖过{cover[i] = 1 ;// 表示此次被覆盖if (link[i] == 0 || find (link[i], color)){link[i] = cur ;// 形成了新的交替链return 1 ;}}return 0 ;}int getRes (int color){int i, sum ;sum = 0 ;memset (link, 0, sizeof (link)) ;// 每一种颜色link 都要初始化for (i = 1 ; i <= n ; ++i){memset (cover, 0, sizeof (cover)) ;sum += find (i, color) ;}return sum ;}int main (){int i, j, res, iRecord ;while (scanf ("%d%d", &n, &k), n | k){iRecord = 0 ;memset (map, 0, sizeof (map)) ;// 图表,记录气球分布memset (count, 0, sizeof (count)) ;// 记数,记录各颜色的气球出现次数memset (record, 0, sizeof (record)) ;// 记录,记录符合题意的气球for (i = 1 ; i <= n ; ++i)for (j = 1 ; j <= n ; ++j){scanf ("%d", &map[i][j]) ;++count[map[i][j]] ;// 记录各颜色气球的出现次数}for (i = 1 ; i <= 50 ; ++i)if (count[i] && getRes (i) > k)// 如果i 颜色气球出现过,且打破所有record[iRecord++] = i ;// i 的次数大于k if (!iRecord)printf ("-1\n") ;else{for (i = 0 ; i < iRecord - 1 ; ++i)printf ("%d ", record[i]) ;printf ("%d\n", record[i]) ;}}return 0 ;}
- 杭电 hdu 1498 50 years, 50 colors (二分图,最大匹配)
- hdu 1498 50 years, 50 colors 二分图最大匹配
- 杭电-1498 50 years, 50 colors(二分匹配)
- hdu 1498 50 years, 50 colors(二分图匹配)
- hdu 1498 50 years, 50 colors( 二分图最大匹配)
- 【杭电1498】50years,50colors二分最大匹配--最小点覆盖
- hdu 1498 50 years, 50 colors 二分图匹配
- HDU 1498 50 years, 50 colors(匈牙利算法 二分最大匹配数)
- hdu 1498 50 years, 50 colors (二分匹配)
- HDOJ 1498 —— 50 years, 50 colors 二分图匹配(最小点覆盖 = 最大二分匹配)
- HDU 1498 50 years, 50 colors(二分最大匹配之最小点覆盖)
- 【二分图匹配(最小顶点覆盖)】hdu 1498 50 years,50 colors
- hdu 1498 50 years, 50 colors 二分匹配
- hdu-1498-50 years,50 colors(最大匹配,行列建图法)
- HDU 1498 50 years, 50 colors (二分图)
- 杭电 1498 50 years, 50 colors【二分匹配+最小点覆盖问题】
- hdu 1498 50 years, 50 colors(二分图匹配--最小点覆盖)
- HDU 1498(50 years, 50 colors)x轴和y轴的二分匹配
- 运算符重载
- 北京是个人吃人的地方
- git简单设置
- c++ 获取文件后缀名
- 清除文本框内容的解决方法(个人见解)
- 杭电 hdu 1498 50 years, 50 colors (二分图,最大匹配)
- 笔记本手机防盗软件
- Android-StageFright之数据流的封装和AwesomePlayer流程
- 判断文件或文件目录是否存在
- 扇形陷阱和断层陷阱(即当一个实体有多个一对多关系时)
- 数学之美番外篇:平凡而又神奇的贝叶斯方法
- hackthissite realistic mission 2
- linux命令---修改密码
- uva 12018 Juice Extractor 谷歌杯程序设计大赛