The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3775    Accepted Submission(s): 1771 Problem Description There are a group of students. Some of them may know each ot…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description There are a group of students. Some of them may know each other, while others don't. For example, A and B know each o…
The Accomodation of StudentsTime Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8939    Accepted Submission(s): 3925 Problem DescriptionThere are a group of students. Some of them may know each othe…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2444 题意:首先判断所有的人可不可以分成互不认识的两部分.如果可以分成 ,则求两部分最多相互认识的对数. 思路:二分图最大匹配问题.先BFS判断是否为二分图,再用匈牙利算法算最大匹配量 关于匈牙利算法:https://blog.csdn.net/CillyB/article/details/55511666 代码: #include<iostream> #include<cstdio>…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2444 Problem Description There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. But this may not imply t…
[题目链接]:pid=2444">click here~~ [题目大意]: 给出N个人和M对关系,表示a和b认识,把N个人分成两组,同组间随意俩人互不认识.若不能分成两组输出No,否则输出两组间俩人互相认识的对数 [解题思路]:   先推断是否能构成二分图,推断二分图用交叉染色法:从某个未染色的点出发把此点染成白色,该点周围的点染成黑色.黑色周围的又染成白色.若走到某个点已经染色,而且它相邻点的颜色与它一样则不是二分图,能够这样理解,染白色既增加X集合,黑色既增加Y集合,若某个点即是X集合…
此题就是求最大匹配.不过需要判断是否构成二分图.判断的方法是人选一点标记为红色(0),与它相邻的点标记为黑色(1),产生矛盾就无法构成二分图.声明一个vis[],初始化为-1.通过深搜,相邻的点不满足异或关系就结束.如果没被标记,就标记为相邻点的异或. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> using na…
这是一个基础的二分图,题意比较好理解,给出n个人,其中有m对互不了解的人,先让我们判断能不能把这n对分成两部分,这就用到的二分图的判断方法了,二分图是没有由奇数条边构成环的图,这里用bfs染色法就可以判断,其次让我们求分在两部分的最大对数,这就是二分图的最大匹配问题,这里数据只有200,所以匈牙利算法求蹭广路径的办法可以解决这个问题,也相对比较容易编写. 另外一开始我链式前向星的数组开小了,G++居然返回超时,后来换了C++才RE,想到数组越界的问题,不得不说这些编译器真傲娇啊- #includ…
There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. But this may not imply that A and C know each other. Now you are given all pairs of students who know…
题目来源:HDU 2444 The Accomodation of Students 题意:n个人能否够分成2组 每组的人不能相互认识 就是二分图判定 能够分成2组 每组选一个2个人认识能够去一个双人间 最多能够有几组 思路:二分图判定+最大匹配 #include <cstdio> #include <cstring> #include <vector> using namespace std; const int maxn = 550; int vis[maxn];…
http://acm.hdu.edu.cn/showproblem.php?pid=2444 The Accomodation of Students Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 2444 Description There are a group of students. Some of them may know…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3565    Accepted Submission(s): 1659 Problem Description There are a group of students. Some of them may know each ot…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7086    Accepted Submission(s): 3167 Problem Description There are a group of students. Some of them may know each o…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2444 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description There are a group of students. Some of them may know each other, while others don't. For ex…
题目大意:有一群人他们有一些关系,比如A认识B, B认识C, 但是这并不意味值A和C认识.现在给你所有互相认识的学生,你的任务是把所有的学生分成两个一组, 住在一个双人房里.相互认识的同学可以住在一个双人房里. 输入数据: 有n个学生 m个关系(m对是相互认识的) 接下来m行是,是m个关系. 如果能够匹配成功则输出需要双人房的个数,否则输出'No'   思路:先判断是否是个二分图,可以使用黑白染色的方法来判断.然后再进行最大匹配.   #include<stdio.h> #include<…
There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. But this may not imply that A and C know each other. Now you are given all pairs of students who know…
题目链接 题意:n个学生,m对关系,每一对互相认识的能住一个房间.问否把这些学生分成两组,要求每组的学生都互不认识.求最多须要多少个房间. 能否分成两组?也就是说推断是不是二分图,推断二分图的办法,用染色法 把初始点染成黑色,然后与之相连的染成白色,反复,使路径黑白相间, 假设当前点的颜色和与他相连点的颜色同样时,则说明这个图不是二分图 求最多须要多少个房间?也就是求最大匹配数. #include <iostream> #include <cstdio> #include <…
本题就是先推断能否够组成二分图,然后用匈牙利算法求出最大匹配. 究竟怎样学习一种新算法呢? 我也不知道什么方法是最佳的了,由于看书本和大牛们写的匈牙利算法具体分析,看了几乎相同两个小时没看懂,最后自己直接看代码,竟然不到半个小时看懂了.然后就能够直接拿来解题啦. 比方topcoder上有这个算法的非常具体的分析.真没看懂. 代码竟然比分析更清晰了?我也不好下结论. 可是我认为基本的思想还是有作用的. 说说我对这个算法的理解吧: 1 假设二分图分为两个集合 U, V,那么从一个集合U出发 2 U的…
题意: 有一堆的学生关系,要将他们先分成两个组,同组的人都不互不认识,如果不能分2组,输出No.若能,则继续.在两组中挑两个认识的人(每组各1人)到一个双人房.输出需要多少个双人房? 思路: 先判定是否为二分图,可以用黑白着色法(DFS或BFS都行).若是二分图,再进行匹配,用匈牙利算法,注:给的是整个图,没有区分男女,用邻接表比较好. #include <bits/stdc++.h> #define LL long long using namespace std; ; vector<…
首先是要构造二分图,然后二分图的最大匹配. 还有没完全证明过我的方法的正确性,但是AC了..... #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<queue> #include<algorithm> using namespace std; const int INF=0x7FFFFFFF; *+; +; int N,M; in…
#include<iostream> #include<cstdio> #include<cstring> #define maxn 2010 using namespace std; int n,m,num,head[maxn],f[maxn],match[maxn],color[maxn]; struct node { int u,v,pre; }e[maxn*maxn]; void Add(int from,int to) { num++; e[num].u=fr…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5225    Accepted Submission(s): 2374 Problem Description There are a group of students. Some of them may know each ot…
染色判读二分图+Hungary匹配 The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1705    Accepted Submission(s): 821 Problem Description There are a group of students. Some of them…
链接: https://vjudge.net/problem/HDU-2444#author=634579757 题意: There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. But this may not imply that A and C know…
http://acm.hdu.edu.cn/showproblem.php?pid=2444 题意:给出边,判断这个是否是一个二分图,并求最大匹配. 思路:先染色法求出是否是一个二分图,然后再匈牙利求出最大匹配.注意输出是"No"而不是"NO"!!! #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <…
http://acm.hdu.edu.cn/showproblem.php?pid=2444 Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7087    Accepted Submission(s): 3168 Problem Description There are a group of students. Some of the…
图论的题目.着色原理+二分图匹配. #include <cstdio> #include <cstring> #define MAXN 205 char map[MAXN][MAXN]; int link[MAXN]; int color[MAXN]; bool visit[MAXN]; int n, m; bool dfs(int v, int col) { int i; ; i<=n; ++i) { if (map[i][v]) { if (color[i] == col…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1068 Problem Description the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically involved" is defined between one girl…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2063  解题思路: 二分图最大匹配模板题. AC代码: #include<stdio.h> ][],match[],book[],z; int dfs(int u); int main() { int t,n,m,sum,i,j,a,b; ) { scanf("%d%d",&n,&m); z=n+m; ;i<=z;i++) ;j<=z;j++) e…
#include<stdio.h> #include<string.h> #include<queue> using namespace std; #define maxn 210 int map[maxn][maxn],color[maxn]; int vis[maxn],match[maxn],n; int bfs(int u,int n) { int i; queue<int>q; q.push(u); color[u]=; while(!q.empt…