题解: 树的最长路径,根据树的最长路径的性质,从任一一点bfs得到最远的点的位置,然后再从该点重新bfs一次就可以得到树的直径了 数学证明http://www.cnblogs.com/wuyiqi/archive/2012/04/08/2437424.html 代码: ...
分类:
其他好文 时间:
2016-09-03 20:59:41
阅读次数:
117
题意:给定一个有向图,然后你可能改变某一些边的方向,然后就形成一种新图,让你求最多有多少种无环图。 析:假设这个图中没有环,那么有多少种呢?也就是说每一边都有两种放法,一共有2^x种,x是边数,那么如果有环呢?假设x是这个连通块的边数, y是这个环的边数,那么就一共有2^x * (2 ^ y - 2 ...
分类:
其他好文 时间:
2016-08-31 02:03:44
阅读次数:
154
题目链接:http://codeforces.com/problemset/problem/711/D 给你一个n个节点n条边的有向图,可以把一条边反向,现在问有多少种方式可以使这个图没有环。 每个连通量必然有一个环,dfs的时候算出连通量中点的个数y,算出连通量的环中点的个数x,所以这个连通量不成 ...
分类:
其他好文 时间:
2016-08-30 19:35:31
阅读次数:
195
D. Directed Roads D. Directed Roads ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of n to ...
分类:
移动开发 时间:
2016-08-30 18:02:01
阅读次数:
456
题目链接:http://codeforces.com/contest/711/problem/D 熄灯了明天填坑… ...
分类:
移动开发 时间:
2016-08-30 00:06:59
阅读次数:
312
[1635] Explosion 时间限制: 10000 ms 内存限制: 65535 K 问题描述 there is a country which contains n cities connected by n - 1 roads(just like a tree). If you place ...
分类:
其他好文 时间:
2016-08-28 16:24:44
阅读次数:
219
1、HDU 1102 Constructing Roads 最小生成树 2、总结: 题意:修路,裸题 (1)kruskal //kruskal #include<iostream> #include<cstring> #include<cmath> #include<queue> #include< ...
分类:
其他好文 时间:
2016-08-28 01:13:18
阅读次数:
253
Description Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of ...
分类:
其他好文 时间:
2016-08-22 00:17:21
阅读次数:
221
Description Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of ...
分类:
其他好文 时间:
2016-08-21 13:42:40
阅读次数:
223
Bakery Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose ...
分类:
其他好文 时间:
2016-08-21 00:50:05
阅读次数:
164