题意: 给出一个图的所有边,每次从图中删除一条边,求任意点对的路径总和(求完了就将边给补回去).(有重边) 思路: #include <bits/stdc++.h> using namespace std; , INF=0x7f7f7f7f; int mapp[N][N]; bool vis[N]; //是否存在队列中 int dest[N]; vector<pair<int,int> > vect; int n, m; int num[N]; void spfa(in…
http://acm.hdu.edu.cn/showproblem.php?pid=2433 题意: 求删除任意一条边后,任意两点对的最短路之和 以每个点为根节点求一个最短路树, 只需要记录哪些边在最短路树上,记录整棵树的dis和 如果删除的边不在最短路树上,累加记录的dis和 否则,重新bfs求dis和 因为最短路树上有n-1条边,n棵树,所以只有(n-1)*n条边需要重新bfs 时间复杂度为n*n*m 求桥是 对面的low>自己的dfn,我求了一年假的桥 my god ! ლ(ٱ٥ٱლ) #…
Problem Description       One day, Tom traveled to a country named BGM. BGM is a small country, but there are N (N <= 100) towns in it. Each town products one kind of food, the food will be transported to all the towns. In addition, the trucks will a…
 One day, Tom traveled to a country named BGM. BGM is a small country, but there are N (N <= 100) towns in it. Each town products one kind of food, the food will be transported to all the towns. In addition, the trucks will always take the shortest w…
HDU 2717 题目大意:在x坐标上,农夫在n,牛在k.农夫每次可以移动到n-1, n+1, n*2的点.求最少到达k的步数. 思路:从起点开始,分别按x-1,x+1,2*x三个方向进行BFS,最先找到的一定是最小的步数. /* HDU 2717 Catch That Cow --- BFS */ #include <cstdio> #include <cstring> #include <queue> using namespace std; ]; int n, k…
Hunter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2014    Accepted Submission(s): 615 Problem Description One day, a hunter named James went to a mysterious area to find the treasures. Jame…
基本的树上删边游戏 写过很多遍了 /** @Date : 2017-10-13 18:19:37 * @FileName: HDU 3094 树上删边 NIM变形.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/stdc++.h> #define LL long long #d…
pid=5380">题目链接:hdu 5380 Travel with candy 保持油箱一直处于满的状态,维护一个队列,记录当前C的油量中分别能够以多少价格退货,以及能够推货的量.每到一个位置,能够该商店的sell值更新队列中全部价格小于sell的(还没有卖). 用buy值更新队列中大于buy(卖掉了).移动所消耗的油从价格最低的開始. #include <cstdio> #include <cstring> #include <algorithm>…
http://acm.hdu.edu.cn/showproblem.php?pid=2433 这个问题因为路径都是1,所以可以用bfs遍历 可以看这几篇文章讲解: http://blog.csdn.net/panyanyany/article/details/7215069 (这篇代码非常清晰,而且效率很高) http://www.cppblog.com/keroro/archive/2013/05/27/200622.html?opt=admin #include <cstdio> #inc…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 689    Accepted Submission(s): 238 Problem Description In graph theory, the complement of a graph G is a graph H on the same vertic…