【构造】UVa 11387 The 3-Regular Graph】的更多相关文章

Description 输入n,构造一个n个点的无向图,使得每个点的度数都为3.不能有重边和自环,输出图或确定无解. Solution 如果n为奇数,奇数*3=奇数,度数为奇,必无解. 考虑我们怎么构造一个图使得每个点度数为2?显然是直接连一个环. 再让他们度数为3,让点两两一连就行了. 秒之. Code 注意n=2虽然是偶数但也无解. #include<cstdio> int main(){ int n; &&n){ ||n%==){ printf("Impossi…
这题写起来真累.. 名次树就是多了一个附加信息记录以该节点为根的树的总结点的个数,由于BST的性质再根据这个附加信息,我们可以很容易找到这棵树中第k大的值是多少. 所以在这道题中用一棵名次树来维护一个连通分量. 由于图中添边比较方便,用并查集来表示连通分量就好了,但是删边不太容易实现. 所以,先把所有的边删去,然后逆序执行命令.当然,C命令也要发生一些变化,比如说顺序的情况是从a变成b,那么逆序执行的话应该就是从b变成a. 最后两棵树的合并就是启发式合并,把节点数少的数并到节点数多的数里去. #…
D. Regular Bridge Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/problem/D Description An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a b…
 Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is cal…
A. Two Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB"…
Regular Bridge An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected un…
D. Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is c…
本文参考自<复杂性思考>一书的第二章,并给出这一章节里我的习题解答. (这书不到120页纸,要卖50块!!,一开始以为很厚的样子,拿回来一看,尼玛.....代码很少,给点提示,然后让读者自己思考怎么实现) 先定义顶点和边 class Vertex(object): def __init__(self, label=''): self.label = label def __repr__(self): return 'Vertex(%s)' % repr(self.label) # __repr…
D. Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is c…
重点:  1.The constructed graph inherits several properties of the series in its structure. periodic series --> regular graphs这句话是错的,periodic series 转化成的图并不是regular graphs, 转化成的图的degree distribution是分形的. fractal series --> scale-free networks. random s…