CF 61D Eternal Victory 图论小思维
(2011-10-08 16:29:06)
标签:
cf61deternalvictory图论小思维it |
分类: 图论 |
题目描述:
无向树,每条边有边权,你在1号点,要求沿着边走,每个点至少走1边的最小花费是多少。
解题报告:
容易发现,只有1~最后一个访问节点的那条路径的边仅仅访问一遍,其他的边均访问了两遍。
那么,求的从1到其他节点的距离,所有边权和的2倍-最大距离就是答案。
代码如下:
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define SIZE 100005
vector<pair<int, int> > g[SIZE];
int n, ans;
void dfs(int id, int fa, int sum)
{
}
int main()
{
}