题意:构造一个有n个顶点,每个点度不超过k,然后给出每一个点到达一个定点的最短距离d数组,然后构造出这样的一个图;思路:排序之后,有两个距离为0的或者没有直接输出-1,然后用两个游动下表,后面的与前面的度都小于k且它们的距离相差1,就建1条边。然后dfs输出就可以。 1 #include 2 #i....
分类:
其他好文 时间:
2015-02-03 17:06:26
阅读次数:
180
Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniq...
分类:
其他好文 时间:
2015-02-02 15:25:58
阅读次数:
193
原题地址方法I,DFS一边遍历一边复制借助辅助map保存已经复制好了的节点对于原图中每个节点,如果已经复制过了,直接返回新节点的地址,如果没复制过,则复制并加入map中,接着依次递归复制其兄弟。代码: 1 map old2new; 2 3 UndirectedGraphNode *cloneGra....
分类:
其他好文 时间:
2015-02-02 00:36:32
阅读次数:
153
出于兴趣一直以来都断断续续看过dshow的东西,可没怎么系统地总结过(学习还是要多实践,多总结啊).
dshow预览摄像头捕捉的视频比较简单基础,网上相关的资料很多,简单的思路由下面代码所示:
ICaptureGraphBuilder2 *pBuild; // Capture Graph Builder
// Initialize pBuild (not shown).
IBaseFilter...
分类:
其他好文 时间:
2015-02-01 23:19:48
阅读次数:
289
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3549Network flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out ...
分类:
其他好文 时间:
2015-02-01 18:57:24
阅读次数:
236
uva 193 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 bl...
分类:
其他好文 时间:
2015-02-01 13:33:32
阅读次数:
169
拓扑排序的算法package ToPu;public class Graph { private final int MAX_VERTS = 20; private Vertex vertexList[]; private int adjMat[][]; private int nVerts; pr...
分类:
编程语言 时间:
2015-01-31 00:21:25
阅读次数:
255
题目链接:http://codeforces.com/problemset/problem/506/D
题目大意:
给出n个顶点,m条边,每条边上有一个数字,代表某个颜色。不同数字代表不同的颜色。有很多个询问,每个询问问有多少条纯种颜色的路径使得某两个点联通。
分析:
这个题一看就想用并查集来搞,每种颜色用一个并查集处理。对于输入的每条边,我们只需要将这两个点在这条边的颜色对应的并查集中合...
分类:
其他好文 时间:
2015-01-30 09:05:02
阅读次数:
697
.graph { width: 400px; height: 25px; border: 1px solid #f8b3d0; }.bar { background-color: #ffe7f4; display: block; float: left; height: 100%; text-ali...
分类:
Web程序 时间:
2015-01-29 15:55:13
阅读次数:
169
题目:
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:
Only one letter can be changed at a timeEach intermediate...
分类:
编程语言 时间:
2015-01-29 09:34:19
阅读次数:
1950