/*655.二分图-安排房间 (10分)C时间限制:3000 毫秒 |  C内存限制:3000 Kb题目内容: 有一群学生,他们之间有的认识有的不认识.现在要求把学生分成2组,其中同一个组的人相互不认识.如果你分成功了,那么就安排双人间,安排的规矩是两个人分别属于不同的组,并且认识.输入描述首先输入两个整数n,m,表示有n个学生, m个认识对随后m行表示认识的学生对. 输出描述如果不能分组成功则输出“No”否则输出有多少个房间安排学生配对. 输入样例4 41 21 31 42 36 51 21…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8418    Accepted Submission(s): 3709 Problem Description There are a group of students. Some of them may know each ot…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2444 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82834#problem/B 题意: 有n个学生,有m对人是认识的,每一对认识的人能分到一间房,问能否把n个学生分成两部分,每部分内的学生互不认识,而两部分之间的学生认识.如果可以分成两部分,就算出房间最多需要多少间,否则就输出No. 朋友的朋友不是朋友,r代表他们之间的关系 代码: #…
题意:现在有一些学生给你一下朋友关系(不遵守朋友的朋友也是朋友),先确认能不能把这些人分成两组(组内的人要相互不认识),不能分的话输出No(小写的‘o’ - -,写成了大写的WA一次),能分的话,在求出来一对朋友可以住一个房间,最多可以开多少双人房(- -) 分析:使用并查集分组,如果出现矛盾就是不能分,可以分的话再用一组的成员求出最大匹配就OK了,还是比较水的.... ***************************************************************…
链接: 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…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6983    Accepted Submission(s): 3120 Problem Description There are a group of students. Some of them may know each ot…
题意: 给一个图,问能否给每个点分配一个实数值,使得存在一个数实数T,所有点满足:|value(i)| < T 且 u,v之间有边<=> |value(u)-value(v)| >= T.(注意等价符号) 思路: 由性质可得,两相邻点的分配的值的符号相反,于是先对原图做一个二分图判定,如果是非二分图,则无解.对二分图染色后,假设color[i]=1,则表示i点为正值,color[i]=-1,则表示为负.在已知每个点正负值的基础上,绝对值符号可以去掉,差分约束模型便出来了.这里有个细…
题目来源: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) 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 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 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…
hdu_2444The Accomodation of Students(二分图的判定和计算) 标签:二分图匹配 题目链接 题意: 问学生是否能分成两部分,每一部分的人都不相认识,如果能分成的话,两两认识的人可以去开房哈.求最大的开房数. 题解: 二分染色,黑白染色来看这个图可以被染成一个二分图,如果可以的话求出二分图匹配的个数即可 注意事项: dfs来染色,在求解的时候注意点的编号是从0还是从1开始的 代码: //二分图最好用链表存图 #include<cstdio> #include<…
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): 4915    Accepted Submission(s): 2260 Problem Description There are a group of students. Some of them may know each o…
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…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9477    Accepted Submission(s): 4165 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2444 Description: There are a gro…
染色判读二分图+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…
The Accomodation of Students Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u 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 k…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2244 Accepted Submission(s): 1056 Problem Description There are a group of students. Some of them may know each other,…
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…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4091    Accepted Submission(s): 1876 Problem Description There are a group of students. Some of them may know each ot…
题目链接:https://vjudge.net/problem/HDU-2444 The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7328    Accepted Submission(s): 3270 Problem Description There are a group o…
<题目链接> 题目大意: 有N个人,M组互相认识关系互相认识的两人分别为a,b,将所有人划分为两组,使同一组内任何两人互不认识,之后将两个组中互相认识的人安排在一个房间,如果出现单人的情况则不安排房间.输出最大需要安排房间的数量. 解题分析:其实题意就是叫我们先判断该图是否为二分图,如果是的话,给出它的最大匹配.判断是否是二分图,我们可以用BFS或DFS对每个节点进行染色,有直接认识关系的人染成不同颜色,判断再染色的过程中是否发生冲突.最后再用匈牙利求出最大匹配. #include <c…
题意 首先判断所有的人可不可以分成两部分,每部分内的所有人都相互不认识.如果可以分成 则求两部分最多相互认识的对数. 解题 类似分成两组,同组互不相关,就可能使判断是否为二分图 能否分成两部分 则是判断是否是一个二分图.无向图G为二分图的充分必要条件是:G至少有两个顶点,且当存在回路时,其所有回路的长度均为偶数.回路就是环路,也就是判断是否存在奇数环.判断二分图方法:用染色法,把图中的点染成黑色和白色.首先取一个点染成白色,然后将其相邻的点染成黑色,如果发现有相邻且同色的点,那么就退出,可知这个…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4250    Accepted Submission(s): 1946 Problem Description There are a group of students. Some of them may know each ot…
和以前做过的一个二分图颇为相似,以前的是互相不认识的放在一组,这个是互相认识的,本质上是相同的 是 hdu 2444 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<map> using namespace std; typedef long…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3478 思路分析:该问题需要求是否存在某一个时刻,thief可能存在图中没一个点:将该问题转换为图论问题即为判断该图是否为一个连通图且不为二分图: (1)二分图的性质:对于无向图G=(V, E),如果可以将图中的点划分为两个不相交的点集X与Y = V - X(V为点集),使得图中所有的边邻接的两个点分别存在集合X与集合Y中,则称该图G为二分图: (2) 二分图判定算法:二分图一种判定方法是给图中的每一…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6424    Accepted Submission(s): 2880 Problem Description There are a group of students. Some of them may know each o…
A. NP-Hard Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very int…