<题目链接> 题目大意: Hugo Heavy要从城市1到城市N运送货物,有M条道路,每条道路都有它的最大载重量,问从城市1到城市N运送最多的重量是多少. 解题分析: 感觉这道题用dijkstra不是很好想,有点抽象.我反而觉得这道题用最大流比较好想,比如EK算法,用BFS求出所有1->n的增广路径,然后求出每条增广路径的最小值,就可最终得到这些最小值中的最大值. #include <iostream> #include <cstring> #include &l…
F - Heavy Transportation Time Limit:3000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand busines…
题目链接: http://poj.org/problem?id=1797 Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has buil…
Heavy Transportation 题目链接: http://acm.hust.edu.cn/vjudge/contest/66569#problem/A Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether th…
http://poj.org/problem?id=1797 题意 :给出N个城市M条边,每条边都有容量值,求一条运输路线使城市1到N的运输量最大. 思路 :用dijkstra对松弛条件进行变形.解释一下样例吧:从1运到3有两种方案方案1:1-2-3,其中1-2承重为3,2-3承重为5,则可以运送货物的最大重量是3(当大于3时明显1到不了2)方案2:1-3,可知1-3承重为4,故此路可运送货物的最大重量是4,故答案输出4 #include <iostream> #include <std…
Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant steel crane t…
Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant steel crane t…
题意:题目大意:有n个城市,m条道路,在每条道路上有一个承载量,现在要求从1到n城市最大承载量,而最大承载量就是从城市1到城市n所有通路上的最大承载量 链接:点我 解题思路:其实这个求最大边可以近似于求最短路,只要修改下找最短路更新的条件就可以了 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<…
POJ.1797 Heavy Transportation (Dijkstra变形) 题意分析 给出n个点,m条边的城市网络,其中 x y d 代表由x到y(或由y到x)的公路所能承受的最大重量为d,求从1到n的所有通路中,所能经过的的最大重量的车为多少. 2. 代码总览 #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <stack&…
题目链接:POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant…
Heavy Transportation Time Limit:3000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. B…
POJ 1797 Heavy Transportation / SCU 1819 Heavy Transportation (图论,最短路径) Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there reall…
Heavy Transportation POJ 1797 最短路变形 题意 原题链接 题意大体就是说在一个地图上,有n个城市,编号从1 2 3 ... n,m条路,每条路都有相应的承重能力,然后让你求从编号为1的城市到编号为n的城市的路线中,最大能经过多重的车. 解题思路 这个题可以使用最短路的思路,不过转移方程变了\(dis[j]=max(dis[j], min(dis[u], e[u][j]))\).这里dis[j]表示从标号为1的点到达编号为j的点的路径中,最小的承重能力,就像短板效应样…
题目链接:POJ 1797 Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant…
POJ 3356 AGTC(最小编辑距离) http://poj.org/problem?id=3356 题意: 给出两个字符串x 与 y,当中x的长度为n,y的长度为m,而且m>=n.然后y能够经过删除一个字母,加入一个字母,转换一个字母,三种操作得到x.问最少能够经过多少次操作 分析: 我们令dp[i][j]==x表示源串的前i个字符变成目串的前j个字符须要x步操作. 初始化: dp[0][i]==i且 dp[i][0]=i. 上述前者表示加入源串i个字符, 后者表示删除源串i个字符. 状态…
poj 1797 Heavy Transportation Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has…
1344:[例4-4]最小花费 Dijkstra (1)a [ i ] [ j ] 存转账率(..转后所得率..) (2)dis [ i ] 也就是 a [ 起点 ] [ i ] (3)f [ i ] 判断是否已经拓展过 (4)前驱结点 k PS:ans * a[x][y]=100 即 ans=100 / a[x][y] 代码: #include<iostream> #include<algorithm> #include<cstdio> #include<cst…
Dijkstra经典算法注意点 前言 迪杰斯特拉算法,经典模板如下: void dij(int s) { for(int i=1; i<=n; i++) dis[i]=road[s][i]; vis[s]=1; dis[s]=0; //这句话也可以不加 for(int i=1; i<n; i++) { int tmp=inf, k; for(int j=1; j<=n; j++) { if(!vis[j] && dis[j] < tmp) { tmp=dis[j];…
<题目链接> 题目大意: 给出青蛙A,B和若干石头的坐标,现青蛙A想到青蛙B那,A可通过任意石头到达B,问从A到B多条路径中最小的最长边. 解题分析: 这是最短路的一类典型题目,与普通的最短路的不同之处在于松弛操作. #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> using namespace std; #define N 205 int n;…
题目链接:http://poj.org/problem?id=1797 题意:从路口1运货到路口n,最大的运货重量是多少?题目给出两路口间的最大载重. 思路:j加到s还是接到K下面,取两者的较大者,而使得载重量较大,而接到k下面,载重量是dis[k]和maps[k][j]的较小者. #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define INF 0x…
题目 改动见下,请自行画图理解 具体细节也请看下面的代码: 这个花了300多ms #define _CRT_SECURE_NO_WARNINGS #include<string.h> #include<stdio.h> #include<math.h> #include<algorithm> using namespace std; ; #define typec int ;//防止后面溢出,这个不能太大 bool vis[MAXN]; typec cost…
题目传送门 题意:求1到n的最大载重量 分析:那么就是最大路上的最小的边权值,改变优先规则. #include <cstdio> #include <algorithm> #include <cstring> #include <queue> using namespace std; typedef long long ll; const int N = 1e3 + 10; const int E = 1e5 + 10; const int INF = 0x…
题意 Farmer John想从电话公司修一些电缆连接到他农场.已知N个电线杆编号为1,2,⋯N,其中1号已经连接电话公司,N号为农场,有P对电线杆可连接. 现给出P对电线杆距离Ai,Bi,Li表示Ai和Bi可连接,需要长度为Li的电缆. 电话公司赞助FJ K条免费电缆,额外的支出为剩下所需电缆的最大长度.求出最小费用. 思路 设mid为某条线的长度,长于mid的线放到免费额度里,否则自己掏钱.如果存在一个临界值x,使得长于x的电线数量恰好等于K,这个临界值对应的解就是最优解.如何计算长于mid…
题意:卡车从路上经过,给出顶点 n , 边数 m,然后是a点到b点的权值w(a到b路段的承重),求卡车最重的重量是多少可以从上面经过. 思路:求所有路径中的最小的边的最大值.可以用迪杰斯特拉算法,只需要将模板的路径更新那改一下,具体看代码注释. 注意:数组的初始化为-1或零m因为题意说的权值并不是距离,而是路的承重. 代码如下: #include<stdio.h> #include<iostream> #include<string.h> using namespace…
Muddy Fields Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8881   Accepted: 3300 Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, t…
题目:click here 题意: 有n个城市,m条道路,在每条道路上有一个承载量,现在要求从1到n城市最大承载量,而最大承载量就是从城市1到城市n所有通路上的最大承载量.分析: 其实这个求最大边可以近似于求最短路,只要修改下找最短路更新的条件就可以了. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #i…
Sample Input 1 // T3 3// n m1 2 3//u v w1 3 42 3 5Sample Output Scenario #1:4 # include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # define LL long long using namespace std ; ; c…
Description n个点的无向图,问最少删掉几个点,使得图不连通 n<=50 m也许可以到完全图? Solution 最少,割点,不连通,可以想到最小割. 发现,图不连通,必然存在两个点不连通. 枚举源点汇点,要让源点汇点不连通.源点汇点不能割掉 网络建图: 为了割的是边,所以要点转化成边. 对于每个x,建立x'=x+n,对于不是S.T的点(因为S.T不能割掉),x向x’连一条边权为1的边 对于原图的边e(x,y) x’->y 连接inf的边,y'->x连接inf的边. 边权保证割…
题意:给你所有道路的载重,找出从1走到n的所有路径中载重最大的,即路径最小值的最大值. 思路:和之前的POJ3268很像.我们用Dijkstra,在每次查找时,我们把最大的先拿出来,因为最大的不影响最小值,然后我们更新的时候,如果当前承重比我们新开辟的路的承重的能力差,那就替换成新的. 注意题目所给数据有重边. 代码: #include<cstdio> #include<set> #include<cmath> #include<stack> #includ…
Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has build his giant steel crane to the place…