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…
题目链接:https://cn.vjudge.net/contest/209473#problem/C 先谈一下二分图相关: 一个图是二分图的充分必要条件: 该图对应无向图的所有回路必定是偶环(构成该环形的边的数量为偶数).暂时不证明,后证. 那么怎么判断一个图的回路是奇环还是偶环呢? 交叉染色法. 随机选择一个点,染成红色,把所有跟它相邻的点染成绿色,再由被染色的绿点出发,把相邻的点染成红色…… 即对于一个点和他相邻的点(两个点之间有边相连叫做相邻),颜色必定不同,如果相同,那么是奇环. 例如…
http://blog.csdn.net/lyy289065406/article/details/6756821 http://www.cnblogs.com/wuyiqi/archive/2011/10/19/2217911.html #include "stdio.h" #include "string.h" #define N 1010 int time; int n,m; bool map[N][N]; struct node { int x,y; //i…
用染色法判断二分图是这样进行的,随便选择一个点, 1.把它染成黑色,然后将它相邻的点染成白色,然后入队列 2.出队列,与这个点相邻的点染成相反的颜色 根据二分图的特性,相同集合内的点颜色是相同的,即 但是如果这个图不是二分图,那么就会这样 把与1相邻的点2,3染成白色,然后入队列,然后2出队列,要把与2相邻的点2,3染成黑色,但是都染过了,所以不用染色 但是3的颜色应该与2相反(如果是二分图的话),可是没有相反,所以就不是二分图 #include <stdio.h> #include <…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5971 题意:有n个人,编号为1-n, 已知X个人是good,Y个人是bad,m场比赛,每场比赛都有一个good和一个bad人结合起来,问这n个人是否能被分成两种人 其实就是判断是否为二分图,用染色法判断一下就可以了 #include <stdio.h> #include <string.h> #include <math.h> #include <algorithm&…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3478 题意:有n个路口,m条街,一小偷某一时刻从路口 s 开始逃跑,下一时刻都跑沿着街跑到另一路口,问是否存在某一时刻出,小偷可能出现在任意路口: 如果小偷能走一个环,如果这个环是偶数个节点,那么某个节点只能在偶数时刻或者奇数时刻到达: 但是如果这个环是奇数个节点,他既可以在奇数时刻到达又可以在偶数时刻到达:所以这道题就是求是否存在一个奇环:如果存在输出YES,否则NO: 由于二分图中不能含有奇环,…
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…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2063 女生为X集合,男生为Y集合,求二分图最大匹配数即可. #include<cstdio> #include<iostream> #include<string.h> #include<algorithm> #include<math.h> #include<stdbool.h> #include<time.h> #incl…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1045 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Suppose that we have a square city with straight streets. A map of a city is a square board…
题目链接: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…