题意:N个城市,m条道路需要建设,每条道路由某个公司负责并花费一定的费用,每个公司会向国家纳税,若公司A造1到2的路,B造2到3的路,那么就说A和B有联系。求国家能得到的钱的最大值。ans=纳税之和-建路花费之和。
思路:做最大权闭合图的题就是要找到有相互依赖关系的两个集合。题目中告诉了公司之间有依赖关系,那么就以公司为节点,源点和每个公司连边权为纳税,公司和会点连边权为花费,公司与公司之间有联系的连边权为INF。...
分类:
其他好文 时间:
2015-05-03 09:24:03
阅读次数:
120
最小生成树kruskal算法。
首先必须形成一棵最小生成树,然后找出最长的路。
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int n,m,a,b,c,par[1005],rankk[1005], max_road;
struct edge {
int u,v,c...
分类:
其他好文 时间:
2015-05-01 12:08:49
阅读次数:
147
Ladies and gentlemen, Good evening.I'd rather use english, not mandarin.Because during the road show, I felt so sorry.When I opened my mouth I have to...
分类:
其他好文 时间:
2015-05-01 10:33:26
阅读次数:
168
Problem Description
Ant Country consist of N towns.There are M roads connecting the towns.
Ant Tony,together with his friends,wants to go through every part of the country.
They intend to visit every road , and every road must be visited for exact one t...
分类:
其他好文 时间:
2015-04-27 13:22:54
阅读次数:
148
The road to success was trial and error development, recompilation, and lots of crashes.寒假过去一个月,计划很多时候也没法跟上。不过总体上来说,还是学习和收获了一些东西的。过去的事情不能改变,所以也不必过于纠结和...
分类:
其他好文 时间:
2015-04-27 01:54:21
阅读次数:
175
题意:已知无向图,问添加最少的边使之成为边双连通图
思路:显然先缩点成一棵树,添加最少边使一棵树的边双连通
此处有结论:对于一棵树添加(1+leaf)>>1 条无向边就能构造成一个双连通图,构造方法显然(脑补一下
//216K 63MS C++ 1754B
#include
#include
#include
#include
...
分类:
其他好文 时间:
2015-04-24 09:09:05
阅读次数:
118
Road Construction
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 9465
Accepted: 4699
Description
It's almost summer time, and that means that it's almost ...
分类:
其他好文 时间:
2015-04-23 17:31:27
阅读次数:
134
题意:给出一幅无向图,每次询问给出起点和终点,求起点到终点权值差最小的一条路,输出权值差;思路:边按权值排序,利用并查集枚举每次能使起点终点联通的情况下权值差,并每次更新最小值;#include#include#includeusing namespace std;#define INF 0x3f3...
分类:
其他好文 时间:
2015-04-11 20:36:34
阅读次数:
133
1.One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard t...
分类:
其他好文 时间:
2015-04-10 13:02:27
阅读次数:
123