ACM-ICPC Live Archive 6811 - Irrigation Lines
来源:互联网 发布:软件下载系统网站源码 编辑:程序博客网 时间:2024/05/23 11:52
怎么读题时就没意识到“每行每列各有一个水阀”?这是把问题转化成二分图模型的关键啊
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4823
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4823
#include <iostream>#include <cstring>#include <cstdio>using namespace std; const int MAXN = 110;char graph[MAXN][MAXN];bool visited[MAXN];int nCase, cCase, use[MAXN], m, n; void init() { memset(use, -1, sizeof(use));} void input() { scanf("%d%d", &m, &n); for (int i = 0; i < m; i++) { scanf("%s", graph[i]); }} bool find(int x) { for (int j = 0; j < n; j++) { if (graph[x][j] == '1' && !visited[j]) { visited[j] = true; if (use[j] == -1 || find(use[j])) { use[j] = x; return true; } } } return false;} int match() { int count = 0; for (int i = 0; i < m; i++) { memset(visited, false, sizeof(visited)); if (find(i)) count++; } return count;} void solve() { printf("Case #%d: %d\n", ++cCase, match());} int main() { scanf("%d", &nCase); while (nCase--) { init(); input(); solve(); } return 0;}
0 0
- ACM-ICPC Live Archive 6811 - Irrigation Lines
- ACM-ICPC Live Archive 6505---Metal(二分)
- ACM-ICPC Live Archive 第4889题 Post Office
- ACM-ICPC Live Archive - Home 4329 - Ping pong
- acm/icpc live archive 2481, world final 2002 problem h. silly sort
- acm/icpc live archive regional 1998 europe central problem d, spoj 45 commedia dell arte
- ACM-ICPC Live Archive 6139 - Interval Product (线段树-点更新)
- UVALive 6270 (ACM-ICPC Live Archive: 6270) Edge Case(大数斐波那契)
- UVALive 6275 (ACM-ICPC Live Archive: 6275 ) Joint Venture(二分)
- ACM-ICPC Live Archive Regionals 2014 >> 重拾2014上海区域赛
- ACM-ICPC Live Archive 2031 - Dance Dance Revolution(状态dp)
- UVALive 6811 Irrigation Lines(匈牙利算法)
- 贪心--ACM-ICPC Live Archive3902 Networkt
- AMC-ICPC Live Archive 7295 和 CSU 1715
- UVA Live 5067/acm-icpc-Asia - Tokyo-A
- UVaLive/LA 6811 Irrigation Lines(二部图,最小点覆盖)
- UVALive 6811 Irrigation Lines (二分图最小点覆盖--匈牙利算法)
- 例题8-8 防线(Defense Lines, ACM/ICPC CERC 2010, UVa1471)
- (原创)结构体位域操作
- PHP中VC6、VC9、TS、NTS版本的区别与用法详解
- eclipse kepler 安装JDT
- 左移运算符 注意点
- UVa11181 - Probability|Given(离散条件概率)
- ACM-ICPC Live Archive 6811 - Irrigation Lines
- C语言二分图匹配(3)___Makers of Fine Wands since 382 BC(Hdu 1179)
- javascript学习实录 之八(计算所选商品总价值
- Interleaving String -- leetcode
- matlab注释的方法
- 二叉树的遍历
- javascript学习实录 之六(div开关闭合效果实例)
- 导航栏背景图片
- Spring MVC的自动转换功能 HttpMessageConverter