HDU-4751 Divide Groups 染色问题】的更多相关文章

Divide Groups Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 423    Accepted Submission(s): 161 Problem Description   This year is the 60th anniversary of NJUST, and to make the celebration mor…
Problem Description   This year is the 60th anniversary of NJUST, and to make the celebration more colorful, Tom200 is going to invite distinguished alumnus back to visit and take photos.   After carefully planning, Tom200 announced his activity plan…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4751 题目大意:判断一堆人能否分成两组,组内人都互相认识. 解题思路:如果两个人不是相互认识,该两人之间连边.最终构成一张图,二分匹配. #include<cstdio> #include<cstring> #include<iostream> using namespace std; #define maxn 105 #define maxm 20010 int n,e;…
SDUST的训练赛 当时死磕这个水题3个小时,也无心去搞其他的 按照题意,转换成无向图,预处理去掉单向的边,然后判断剩下的图能否构成两个无向完全图(ps一个完全图也行或是一个完全图+一个孤点) 代码是赛后看的网上大神,所以转载过来了,dfs染色的时候很巧妙,巧妙的用到了就两个无向完全图 #include <cstdio> #include <cstring> #include <cmath> #include <vector> #include <qu…
题目链接 比赛时候,建图建错了.大体算法想到了,不过很多细节都没想好. #include <cstdio> #include <cstring> #include <cmath> #include <queue> #include <algorithm> using namespace std; ]; ][]; ][]; int n,z; void dfs(int x,int step) { int i; if(z) return ; ; i &…
题意 给定一个有向图,问是否能够分成两个有向完全图. 思路 裸的2-sat--我们设一个完全图为0,另一个完全图为1,对于一个点对(u, v),如果u.v不是双向连通则它们两个不能在一组,即u和v至少又一个为0,至少又一个为1.则我们向2-sat中加条u->v', u'->v, v->u', u'->v的边,然后验证可行性即可. (关于2-SAT的建图可以见这篇题解) 代码 [cpp] #define MID(x,y) ((x+y)/2) #define MEM(a,b) mems…
染色判断二分图+补图 比赛的时候题意居然是反的,看了半天样例都看不懂 .... Divide Groups Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 456    Accepted Submission(s): 172 Problem Description   This year is the 60th anniversary o…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4751 题意:有n个人,每个人都认识一些人,要求把他们分成两个集合,使得两个集合中的人都相符两两认识. 如果两个人单向认识或者相互不认识,那么必定在不同的集合,因此建立边,染色就可以了.. //STATUS:C++_AC_31MS_388KB #include <functional> #include <algorithm> #include <iostream> //#i…
Description In the ``Four Color Map Theorem" was proven with the assistance of a computer. This theorem states that every map can be colored using only four colors, in such a way that no region is colored using the same color as a neighbor region. He…
题目链接 Divide Groups Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1153    Accepted Submission(s): 418 Problem Description   This year is the 60th anniversary of NJUST, and to make the celebrati…