图论
文章平均质量分 60
Aoxuets
REM 是我的, 拔剑吧!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
51nod--1212 最小生成树
题目:1212 无向图最小生成树 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 N个点M条边的无向连通图,每条边有一个权值,求该图的最小生成树。 Input 第1行:2个数N,M中间用空格分隔,N为点的数量,M为边的数量。(2 <= N <= 1000, 1 <= M <= 50000) 第2 - M + 1行:每行3个数S E W,分别表示M原创 2016-03-16 21:44:41 · 408 阅读 · 0 评论 -
POJ 3723
最大生成树 #include #include #include #include #include #include #include #include #include #include using namespace std; const int maxn = 50000 + 131; const int maxm = 10000 + 131; struct原创 2016-03-14 11:00:22 · 362 阅读 · 0 评论 -
POJ 3255
题意: 次短路, 裸的板子; #include #include #include #include #include #include #include #include #include using namespace std; const int maxn = 1e5 +131; const int INF = 0x7fffffff; struct Edge{原创 2016-03-14 11:00:20 · 343 阅读 · 0 评论 -
POJ 1659
题意: 给你一个数列, 判断是否可以构成一个图, 可以则输出 构成图的一种方式 构图根据 Havel-Hakimi定理来构图 (在排序的时候注意 节点下标会变化, 故用结构体) #include #include #include #include using namespace std; const int maxn = 50; int Map[maxn][maxn]; struc原创 2016-03-14 10:55:17 · 438 阅读 · 0 评论 -
UVA 1151
MST ; 不过有 Q种 特殊方案,可以只花费C【i】 (0 对于方案的选取,可以状态压缩 先直接生成MST ,并把边存起来; 枚举 状态 对于方案, 链接点, 如有剩下的点没有处理; 则剩下的边必会在原MST中的边选; #include #include #include #include using namespace std; const int maxn = 1000 + 31原创 2016-03-14 10:55:09 · 316 阅读 · 0 评论 -
UVA 1395 MST
给你一个图, 求一个生成树, 边权Max – Min 要最小,输出最小值, 不能构成生成树的 输出 -1; 思路: Keuksal 算法, 先排序边, 然后枚举 第一条边, 往后加入边, 直到有 n-1 条边的树, 求出那个值, 把可能的值取MIN; #include #include #include #include #includeset> using namespace std;原创 2016-03-14 10:55:04 · 323 阅读 · 0 评论 -
HDU 1102
最小生成树 对于必须要加入的边, 让其边权为0 即可 Prim : #include #include #include using namespace std; const int maxn = 100 + 31; const int INF=0x3f3f3f3f; int Map[maxn][maxn]; int Vis[maxn], Dis[maxn]; int ans;原创 2016-03-14 10:55:02 · 342 阅读 · 0 评论 -
51nod--1459 迷宫游戏 (dijkstra)
1459 迷宫游戏 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 你来到一个迷宫前。该迷宫由若干个房间组成,每个房间都有一个得分,第一次进入这个房间,你就可以得到这个分数。还有若干双向道路连结这些房间,你沿着这些道路从一个房间走到另外一个房间需要一些时间。游戏规定了你的起点和终点房间,你首要目标是从起点尽快到达终点,在满足首要目标的前提下,使得你的得原创 2016-03-14 12:47:13 · 747 阅读 · 0 评论 -
Light OJ 1009
题意: 给你一个二分图, (可能不连通) 求可能多的子集元素个数; 思路: 直接DFS 给二分图染色就有了, 统计联通块中个数, 去最大值相加即可。 #include using namespace std; const int maxn = 20000 + 131; struct Node { int One, Zre; }N[maxn / 2]; vector E[原创 2016-03-14 10:59:40 · 382 阅读 · 0 评论 -
Light Oj 1003
题意 : 给你m个二元关系, 问是否可以确定各个节点的先后关系; 思路: 拓扑排序, 判断是否有环; #include using namespace std; const int maxn = 1e4 + 131; struct Node{ int nxt, to; }edge[maxn]; int Head[maxn], tot; void AddEdge(i原创 2016-03-14 10:55:55 · 479 阅读 · 0 评论 -
Uva 10369 (最小生成树)
题意:有 P 个哨站, 哨站之间用 无线电传播。 现在有 S 个卫星, 一个卫星可以连接任意两个哨站。 无线电的最长传播距离为 D。 现在 P 个哨站的坐标, 要求每个哨站之间至少有一条通信通道; 求D 的最小值。分析:先把 P 个哨站看成P 个点,这里总共有 P∗(P−1)2\frac{P * (P-1)}{2} 条边的图; 边权就是距离。 在没有卫星的情况下, 所有无线电的在满足至少原创 2016-07-30 01:09:26 · 736 阅读 · 0 评论 -
HDU 4840(最小生成树)
题目:给你一条蜿蜒曲折的通道, 通道拐角均为直角。有一个小的正方形要通过这个通道。 而通道中是有一些阻碍点的, 正方形不能穿过这些点。现在问你正方形的最大边长是 多少。分析:通道有内外两条边, 看做两个点N,W,阻碍点到通道的距离看做是阻碍点与N,W之间的权值 阻碍点之间的距离也是其相应的权值。这样就把这个问题转化为图了。 图上任意两个点之间的路径上的最长边的最小值是其最小生成树上对应两个点原创 2016-07-30 12:19:43 · 1442 阅读 · 1 评论
分享