Graph Coloring Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4926   Accepted: 2289   Special Judge Description You are to write a program that tries to find an optimal coloring…
嘟嘟嘟 求无向图的最大独立集. 有这么一回事:最大独立集=补图的最大团. 所谓的最大团,就是一个子图,满足图中任意两点都有边. 然后ssy巨佬告诉了我一个很没有道理强的做法:随机. 每一次random_shuffle储存节点的数组,然后从头开始扫每一个点,能加入最大团就加入,否则continue. 最后看看是不是比当前答案优. 一直随机,直到一秒. 我也不知道这有什么道理,但就是过了. .p.s:poj太慢了,得随机到0.3秒(竟然还能过). #include<cstdio> #include…
最大独立集: 顶点集V中取 K个顶点,其两两间无连接. 最大团: 顶点集V中取 K个顶点,其两两间有边连接. 最大独立集=补图的最大团最大团=补图的最大独立集 #include<iostream> #include<cstring> #include<cstdio> using namespace std; ][],mark1[],mark2[]; int n,m; int cnt,maxx; void dfs(int x) { if(x>n) // 如果枚举了所…
Graph Coloring Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5775   Accepted: 2678   Special Judge Description You are to write a program that tries to find an optimal coloring for a given graph. Colors are applied to the nodes of the…
http://poj.org/problem?id=1419 题意: 一张图黑白染色,相邻点不能都染黑色,最多能染几个黑色点 最大点独立集 但是图不能同构为二分图,不能用二分图匹配来做 那就爆搜吧 还可以转化为补图的最大团问题 #include<cstdio> #include<cstring> #include<iostream> using namespace std; ][]; ],res[]; int n,ans,cnt; void read(int &…
题目 Source http://www.lightoj.com/volume_showproblem.php?problem=1171 Description Given an m x n chessboard where some of the cells are broken. Now you are about to place chess knights in the chessboard. You have to find the maximum number of knights…
最大点独立集就是无向图中最多的两两不相邻的点集. 二分图最大点独立集=顶点数-二分图最大边独立集(二分图最大匹配) 这一题男女分别作YX部,如果x和y有浪漫关系则连边,如此构造二分图,答案显然就是最大点独立集.另外要先进行二分图染色,以确定每个id的性别. #include<cstdio> #include<cstring> #include<queue> #include<algorithm> using namespace std; #define IN…
Graph Coloring Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4893   Accepted: 2271   Special Judge Description You are to write a program that tries to find an optimal coloring for a given graph. Colors are applied to the nodes of the…
Graph Coloring You are to write a program that tries to find an optimal coloring for a given graph. Colors are applied to the nodes of the graph and the only available colors are black and white. The coloring of the graph is called optimal if a maxim…
该题反过来想:将所有可能发生恋爱关系的男女配对,那么可以带出去的人数应该等于这个二分图的最大独立集 先要做一下预处理,把不符合要求的双方先求出来, company[i][j]表示i.j四个标准都不符合,即他们可能会成为伴侣. 这里要注意因为x.y集合都是0~n-1,左右对称,所以求最大点独立集的点的个数时,最后还要/2. 接下来就是求最大独立集的点的个数. 最大点独立集+最小点覆盖=点的个数 独立集:在集合中的任意两点都不相邻,即两点间不存在边 #include <iostream> #inc…