大意:给定二分图, 求将边染色, 使得任意邻接边不同色且使用颜色种类数最少 最少颜色数即为最大度数, 要输出方案的话, 对于每一条边(u,v), 求出u,v能使用的最小的颜色$t0$,$t1$ 若t0=t1, 直接染就行不会有冲突, 否则就染为t0, 这样的话可能产生冲突, 就将冲突的边换成t1, 依次递归下去 由于二分图的性质, 最终一定可以找到一条边不冲突 #include <iostream> #include <algorithm> #include <cstdio&…
Discription You are given an undirected bipartite graph without multiple edges. You should paint the edges of graph to minimal number of colours, so that no two adjacent edges have the same colour. Input The first line contains three integers a, b, m…
题意: 输入一个二分图,用最少的颜色数给它的每条边染色,使得同一个顶点连的边中颜色互不相同. 输出至少需要的颜色数和任意一种染色方案. 分析: 证明不会,只说一下(偷瞄巨巨代码学到的)做法. 假设点的最大度数为\(M\),那么至少需要\(M\)种颜色. 下面给出一种构造方法: 对于一条边\((u, \, v)\),分别找出对于\(u\)和\(v\)还没用到的颜色\(c_1\)和\(c_2\). 如果\(c_1=c_2\),直接用颜色\(c_1\)给这条边染色就行了. 如果\(c_1 \neq c…
C. Graph and String 题目连接: http://codeforces.com/contest/624/problem/C Description One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on hi…
题意: 一个无向图的每条边为红色或蓝色,有这样一种操作:每次选一个点,使与其相邻的所有边的颜色翻转. 求解是否可以经过一系列操作使所有的边颜色相同,并输出最少操作次数和相应的点. 分析: 每个点要么选要么不选,也就是对某个点最多进行一次这样的操作. 可以先假设把所有的边变为红色,然后逐个连通分量处理. 对每个连通分量的第一个点,继续枚举是选还是不选. 再根据边的当前颜色和目标颜色,确定相邻顶点选还是不选,相当于二分图染色的过程. 比较两种方案选的点的个数的多少,把较优的保存下来. 然后以把所有的…
Bipartite Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 840    Accepted Submission(s): 285 Problem Description Soda has a bipartite graph with n vertices and m undirected edges. Now he w…
Problem Description Soda has a bipartite graph with n vertices and m undirected edges. Now he wants to make the graph become a complete bipartite graph with most edges by adding some extra edges. Soda needs you to tell him the maximum number of edges…
D - Beautiful Graph CodeForces - 1093D You are given an undirected unweighted graph consisting of nn vertices and mm edges. You have to write a number on each vertex of the graph. Each number should be 11, 22or 33. The graph becomes beautiful if for…
题目传送门 /* 二分图点染色:这题就是将点分成两个集合就可以了,点染色用dfs做, 剩下的点放到点少的集合里去 官方解答:首先二分图可以分成两类点X和Y, 完全二分图的边数就是|X|*|Y|.我们的目的是max{|X|*|Y|}, 并且|X|+|Y|=n. 修正:实现多连通块染色,然后贪心选择,将两个集合个数差大的连通块优先添加,能尽量使得un*vn最大 */ #include <cstdio> #include <algorithm> #include <cstring&…
题意:有\(n\)个点和\(m\)条无向边,现在让你给你这\(m\)条边赋方向,但是要满足任意一条边的路径都不能大于\(1\),问是否有满足条件的构造方向,如果有,输出一个二进制串,表示所给的边的方向. 题解:我们先单独拿出\(3\)个点来看,选择一个点,那么与它相连的另外两个点到自己的方向一定是相同的,同理,我们可以推广到任意一个点,与它相连的所有点到它的方向必须都是一样的才行,其实到这儿就不难看出可以用二分图染色来写了,然后打个板子就能很愉快的AC啦~ 代码: int n,m; int a,…