题意 在n个村庄之间修路使所有村庄连通 其中有些路已经修好了 求至少还需要修多长路
还是裸的最小生成树 修好的边权值为0就行咯
#include
#include
#include
#include
using namespace std;
const int N = 105, M = 10050;
int par[N], n, m, mat[N][N];
int ans;
struc...
分类:
其他好文 时间:
2014-10-23 12:29:17
阅读次数:
200
题意 有n个村子 输入n 然后n-1行先输入村子的序号和与该村子相连的村子数t 后面依次输入t组s和tt s为村子序号 tt为与当前村子的距离 求链接所有村子的最短路径
还是裸的最小生成树咯
#include
#include
#include
using namespace std;
const int N=30,M=1000;
int par[N],n,m,ans;
struct...
分类:
其他好文 时间:
2014-10-23 10:45:21
阅读次数:
174
题意 给你n个点 m条边 求最小生成树的权
这是最裸的最小生成树了
#include
#include
#include
using namespace std;
const int N = 55, M = 3000;
int par[N], n, m, ans;
struct edge{int u, v, w;} e[M];
bool cmp(edge a, edge b){return...
分类:
Web程序 时间:
2014-10-23 10:43:45
阅读次数:
229
题目大意:有一些奶牛在一些牧场里,这些牧场有些单向边,牧场中的牛按照单向边行走,问有哪些牧场所有牛都能到达。
思路:图的连通性本来应该是tarjan或者并查集什么的,但是这个题数据范围是在是太弱了,所以就搜索就行了。
CODE:
#include
#include
#include
#include
#define MAX 10010
using namespac...
分类:
其他好文 时间:
2014-10-22 18:24:57
阅读次数:
229
好题mark
1. 图论方法(最大权闭合子图)
#include
#include
#define min(a,b) ((a)<(b)?(a):(b))
const int N=1110;
const int E=5000;
const int oo=1000000000;
int node,src,dest,ne;
int head[N],work[N],Q[N],dist[N]...
分类:
其他好文 时间:
2014-10-22 18:16:38
阅读次数:
179
题意 求n个点m条边的图的连通子图中最长边的最小值
实际上就是求最小生成树中的最长边 因为最小生成树的最长边肯定是所有生成树中最长边最小的 那么就也变成了最小生成树了 不要被样例坑到了 样例并不是最佳方案 只是最长边与最小生成树的最长边相等 题目是特判 直接用最小生成树做就行
#include
#include
#include
using namespace std;
co...
分类:
Web程序 时间:
2014-10-22 12:57:48
阅读次数:
249
题意 给你农场的邻接矩阵 求连通所有农场的最小消耗
和上一题一样裸的最小生成树
#include
#include
#include
using namespace std;
const int N = 105, M = 10050;
int par[N], ans, n, m, t;
struct edge { int u, v, w;} e[M];
bool cmp(edge a, ...
分类:
Web程序 时间:
2014-10-22 11:02:47
阅读次数:
203
题意 给你n个点的坐标 每个点都可与其它n-1个点相连 求这n个点的最小生成树的权重
裸的最小生成树 直接kruskal咯
#include
#include
#include
#include
using namespace std;
const int N = 105, M = 10050;
double x[N], y[N], ans;
int n, m , par[N];
s...
分类:
其他好文 时间:
2014-10-22 10:05:06
阅读次数:
203
题目:spoj 375. Query on a tree
题意:题意很清晰,就是给你一颗树,每两点之间有权值,然后改变一些权值,问一条路径上的最大值。
分析:入门题目,直接套树链模板
AC代码;
#include
#include
#include
#include
using namespace std;
const int N = 10010;
#define ...
分类:
其他好文 时间:
2014-10-21 12:16:36
阅读次数:
210
图论复习之强连通分量以及缩点—Tarjan算法
by RtPYH
------------------------------------------------------------------------------------------------
【强连通分量以及连通子图】
#define#
在一...
分类:
编程语言 时间:
2014-10-21 01:04:41
阅读次数:
278