Road Construction(poj 3352)】的更多相关文章

题意:求最少天几条边,使这个无向图变成双连通图. /* tarjan缩点后,形成一棵树,求出叶子节点数tot,答案是(tot+1)/2 */ #include<cstdio> #include<cstring> #include<iostream> #define N 1010 using namespace std; int num[N],low[N],instack[N],vis[N],s[N],in[N],belong[N],top,cnt,indexx; int…
POJ 3177 Redundant Paths POJ 3352 Road Construction 题目链接 题意:两题一样的.一份代码能交.给定一个连通无向图,问加几条边能使得图变成一个双连通图 思路:先求双连通.缩点后.计算入度为1的个数,然后(个数 + 1) / 2 就是答案(这题因为是仅仅有一个连通块所以能够这么搞,假设有多个,就不能这样搞了) 代码: #include <cstdio> #include <cstring> #include <algorithm…
1.给定一个连通的无向图G,至少要添加几条边,才能使其变为双连通图. 2.POJ - 3177 Redundant Paths(边双连通分支)(模板)  与这道题一模一样.代码就改了下范围,其他都没动... 3. //边双连通分支 /* 去掉桥,其余的连通分支就是边双连通分支了.一个有桥的连通图要变成边双连通图的话, 把双连通子图收缩为一个点,形成一颗树.需要加的边为(leaf+1)/2(leaf为叶子结点的个数) POJ 3177 给定一个连通的无向图G,至少要添加几条边,才能使其变为双连通图…
Description In order to get from one of the F (1 <= F <= 5,000) grazing fields (which are numbered 1..F) to another field, Bessie and the rest of the herd are forced to cross near the Tree of Rotten Apples. The cows are now tired of often being forc…
[题目大意] http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2249 [题目大意] 一张无向图,建造每条道路需要的费用已经给出, 现在求在起点到每个点都是最短路的情况下的最小修路费用 [题解] 考虑到最后的图一定是树形的,因此只要保留每个点与其父节点之间的边的费用最小值即可 在计算最短路的同时不断更新费用 [代码] #include <cstdio> #include <cstring> #include <…
HDU 5813 Elegant Construction(优雅建造) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Description 题目描述 Being an ACMer requires knowledge in many fields, because problems in this contest may use physics, biology, and…
                                                                                                                                             Road Construction Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11210   Accepted: 5572 Descrip…
Road Construction Descriptions Mercer国王是ACM王国的王者.他的王国里有一个首都和一些城市.令人惊讶的是,现在王国没有道路.最近,他计划在首都和城市之间修建道路,但事实证明他的计划的建设成本远高于预期. 为了降低成本,他决定通过从原计划中删除一些道路来制定新的施工计划.但是,他认为新计划应满足以下条件: 对于每对城市,都有一条连接它们的路线(一组道路). 首都和每个城市之间的最小距离不会改变他原来的计划. 许多计划可能符合上述条件,但King Mercer希…
Scout YYF I Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5565   Accepted: 1553 Description YYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy's base. After overcoming a series difficulties,…
Charm Bracelet    POJ 3624 就是一道典型的01背包问题: #include<iostream> #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; ],b[]; ]; int main() { int n,m,i,j; while(scanf("%d%d",&n,&m)!=EOF) { ;i&l…