hdu 2768】的更多相关文章

求最大留下的观众,观众之间存在不能同时满足的关系,就是矛盾关系, 矛盾关系建边,建边是双向的所以最大匹配要/2 还有一种建图的方法:把观众分成两个集合,一个是投留下猫的,一个是投留下狗的 每个集合间没有矛盾关系,就是二分图了,求出最大匹配, 两种方法都是要求最大独立集 #include<stdio.h> #include<string.h> #define N 510 int map[N][N],n,m,k,match[N],vis[N]; struct op { int love…
Cat vs. Dog Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1422    Accepted Submission(s): 534 Problem Description The latest reality show has hit the TV: ``Cat vs. Dog''. In this show, a bunch…
Cat vs. Dog Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2030    Accepted Submission(s): 774 Problem Description The latest reality show has hit the TV: ``Cat vs. Dog''. In this show, a bunch…
Cat vs. Dog Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2279    Accepted Submission(s): 886 Problem Description  The latest reality show has hit the TV: ``Cat vs. Dog''. In this show, a bun…
题目分析: 一个人要不是爱狗讨厌猫的人,要不就是爱猫讨厌狗的人.一个人喜欢的动物如果离开,那么他也将离开.问最多留下多少人. 思路: 爱猫和爱狗的人是两个独立的集合.若两个人喜欢和讨厌的动物是一样的,那么就建一条边.留下多少人,就是求最大独立集. 最大独立集= 顶点数 - 最大匹配数 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<qu…
暂时只包括与最大匹配相关的问题. 求最大独立集,最小路径覆盖等等大多数题目都可以转化为求最大匹配用匈牙利算法解决. 1.最大匹配(边集) 此类问题最直接,直接用匈牙利算法即可. HDU 2063  过山车 http://acm.hdu.edu.cn/showproblem.php?pid=2063 二分图最大匹配模版题. ZOJ 1654 - Place the Robots http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode…
题意: 有猫C个和狗D个,有V个投票人,每个人喜欢猫讨厌狗或则喜欢狗讨厌猫! 求最多能满足多少投票人. 分析: 两个投票者矛盾的话就连一条边,总数减去最大匹配数/2就是要求的答案 // File Name: ACM/HDU/2768.cpp // Author: Zlbing // Created Time: 2013年08月16日 星期五 15时14分15秒 #include<iostream> #include<string> #include<algorithm>…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 123…
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 123…