H. Capital City[ Color: Black ]Bahosain has become the president of Byteland, he is doing his best to make people's liveseasier. Now, he is working on improving road networks between the cities.If two cities are strongly connected, people can use BFS…
H. Capital City Time Limit: 3000ms Memory Limit: 262144KB This problem will be judged on CodeForcesGym. Original ID: 100676H64-bit integer IO format: %I64d      Java class name: (Any)   Bahosain has become the president of Byteland, he is doing his b…
题目链接:http://codeforces.com/gym/100676/attachments 题意: 有 n 个点,m 条边,图中,边强连通分量之间可以直达,即距离为 0 ,找一个点当做首都,其他点到首都的最大距离最小. 参考:http://www.cnblogs.com/ost-xg/p/6395100.html 仔细研究了大佬的思路,很牛逼,但是也有一点细节遗漏了,但是还是能AC,interesting: 分析: 边双连通:条件比点双连通松一点,体现在程序中,就是存在一个子节点能到达的…
J. Computer Network Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” consists of n servers and m two-way communication links. Two servers can communicate either thr…
题意: n个点,m条边,m <= n <= 100000,边的长度都为1. 点从 0 ~ n-1 编号.开始时图是不连通的,并且没有环. 通过加入一些边后,可以使图连通.要求加入的边不能多余(即生成的图是一棵树). 问连通后的图,任意两点之间的距离的最大值,最小可以是多少? 既然刚开始图不连通也无环,那么就是一些树(特殊情况是点). 于是题目就变成了,如何把很多棵树连起来,使最后生成的树直径最小. 可以想到,如果把两棵直径为 a 和 b 的树加一条边连成一棵,那么直径最小的新树直径为 (a+1…
https://vjudge.net/problem/Gym-100676H 题意: 给出一个n个城市,城市之间有距离为w的边,现在要选一个中心城市,使得该城市到其余城市的最大距离最短.如果有一些城市是强连通的,那么他们可以使用传送门瞬间到达. 思路:因为强连通时可以瞬移,因为是无向图,所以计算边双连通分量然后重新建图,这样,也就不存在环了. 接下来,计算一下树的直径,因为中心城市肯定选在树的直径上,这样才有可能使最大的边最短. #include<iostream> #include<a…
题目链接: http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” consists of n servers and m two-way communication links. Two servers can communicate either through a direct link, or through a chain of links, by relayi…
Warm up Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 5093    Accepted Submission(s): 1131 Problem Description N planets are connected by M bidirectional channels that allow instant transport…
<题目链接> 题目大意:给出一个连通图,问你在这个连通图上加一条边,使该连通图的桥的数量最小,输出最少的桥的数量. 解题分析: 首先,通过Tarjan缩点,将该图缩成一颗树,树上的每个节点都是一个边双连通分量,树上的每条边都是桥,现在需要挑出两个点,将它们直接相连,这样它们原始路径上所有的桥因为形成了环而全部消失,因此为了使剩下的桥最少,我们需要找到路径上桥最多的两点,又由于缩点后,树的每条边都是桥,所以这里就转化为树上距离两点的最远距离,也就是求树的直径. 下面Tarjan的时候需要注意的是…
Warm up Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4612 Description N planets are connected by M bidirectional channels that allow instant transportation. It's always possible to travel bet…