find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2702    Accepted Submission(s): 974 Problem Description Marica is very angry with Mirko because he found a new gi…
find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2524    Accepted Submission(s): 888 Problem Description Marica is very angry with Mirko because he found a new gi…
Problem Description Marica is very angry with Mirko because he found a new girlfriend and she seeks revenge.Since she doesn't live in the same city, she started preparing for the long journey.We know for every road how many minutes it takes to come f…
http://acm.hdu.edu.cn/showproblem.php?pid=1595 这道题我用spfa在枚举删除边的时候求最短路超时,改用dijkstra就过了. #include <cstdio> #include <queue> #include <cstring> #include <algorithm> #define maxn 1001 using namespace std; <<; int g[maxn][maxn]; i…
http://acm.hdu.edu.cn/showproblem.php?pid=1595 大致题意: 给一个图.让输出从中删除随意一条边后所得最短路径中最长的. . 思路: 直接枚举每条边想必是不行的.事实上有些边是不须要枚举的,由于删除它们并不影响起点到终点的最短路.起作用的边都是未删边前的最短路径上的边,删除它们最短距离肯定增大,仅仅需在这些最短距离中求最大的就可以. 记录最短路径上的边,仅仅需一个pre数组记录松弛时每一个点的前驱节点. #include <stdio.h> #inc…
转载请注明出处:http://blog.csdn.net/a1dark 分析:经典的次短路问题.dijkstra或者SPFA都能做.先找出最短路.然后依次删掉没条边.为何正确就不证明了.了解思想直接A掉.注意记录路径 #include<stdio.h> #include<string.h> #define INF 0x7ffffff #define N 1010 int mpt[N][N]; int path[N]; int n,m; void init(){ for(int i=…
//给一个无向图,问删除一条边,使得从1到n的最短路最长 //问这个最长路 //这个删除的边必定在最短路上,假设不在.那么走这条最短路肯定比其它短 //枚举删除这条最短路的边,找其最长的即为答案 #include<cstdio> #include<cstring> #include<iostream> using namespace std ; const int maxn = 1110 ; const int inf = 0x3f3f3f3f; struct Edge…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1595 find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1665    Accepted Submission(s): 588 Problem Description Mari…
find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1916    Accepted Submission(s): 668 Problem Description Marica is very angry with Mirko because he found a new g…
find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2692    Accepted Submission(s): 971 Problem Description Marica is very angry with Mirko because he found a new gi…
题目地址:pid=5373">HDU 5373 题意:给你一个数n和操作次数t,每次操作将n的各位数之和求出来放在n的末尾形成新的n,问t次操作后得到的n能否够被11整除. 思路:就是简单的模拟一下乱搞.额,对于%11有一个性质,当一个数的奇数位之和与偶数位之和的差的绝对值能被11整除,那么该数就能够被11整除. #include <stdio.h> #include <math.h> #include <string.h> #include <s…
题目链接: 点我 题意: 给定一个\(n\)个点,\(m\)条边的带权无向图,起点为\(1\),终点为\(n\),现在可以删去其中的一条边,求一种删边方案使得剩下图的最短路值最大,输出这个最短路的长度. 题目保证删去任意一条边都能使得\(1\)与\(n\)连通,且边权均为正值. 题目分析: 首先用\(Dijkstra\)跑出原图的最短路,由于在最短路之外删边对图的最短路没有影响,所以考虑在最短路上删边,直接暴力跑\(Dijkstra\). 需要注意的是,这里不会超时的原因是一个有\(n\)个点的…
题目链接: PKU:http://poj.org/problem? id=3653 ZJU:problemId=1934" target="_blank">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1934 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=2722 Description The Gorelians are a warlike rac…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=21068 Yesterday Vasya and Petya quarreled badly, and now they don't want to see each other on their way to school. The problem is that they live in one and the same house, leave the hou…
http://acm.hdu.edu.cn/showproblem.php?pid=3790 有两个条件:距离和花费.首先要求距离最短,距离相等的条件下花费最小. dijkstra,仅仅是在推断条件时多考虑了花费. 注意重边. #include <stdio.h> #include <algorithm> #include <set> #include <map> #include <vector> #include <math.h>…
Delay Constrained Maximum Capacity Path Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1839 Description Consider an undirected graph with N vertices, numbered from 1 to N, and M edges. The vertex numbered with…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3035 题意 给个图,求把s和t分开的最小割. 分析 实际顶点和边非常多,不能用最大流来求解.这道题要用平面图求最小割的方法: 把面变成顶点,对每两个面相邻的边作一条新边.然后求最短路就是最小割了. 另外,外平面分成两个点,分别是源点和汇点,源点连左下的边,汇点连右上的边,这样跑出来才是正确的. 建图参考自:https://blog.csdn.net/accelerator_/article/deta…
http://acm.hdu.edu.cn/showproblem.php?pid=5876 题意: 在补图中求s到其余各个点的最短路. 思路:因为这道题目每条边的距离都是1,所以可以直接用bfs来做. 处理的方法是开两个集合,一个存储当前顶点可以到达的点,另一个存储当前顶点不能到达的点.如果可以到达,那肯定由该顶点到达是最短的,如果不能,那就留着下一次再判. #include<iostream> #include<algorithm> #include<cstring>…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem Description In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if…
HDU 4849 Wow! Such City! 题目链接 题意:依照题目中的公式构造出临接矩阵后.求出1到2 - n最短路%M的最小值 思路:就依据题目中方法构造矩阵,然后写一个dijkstra,利用d数组取求答案就可以 代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const long long…
[题意]给出一个图,求 1 -> n的2条 没有重边的最短路. 真◆神题--卡内存卡得我一脸血= =-- [思路] 一开始我的想法是两遍Dijkstra做一次删一次边不就行了么你们还又Dijkstra预处理又最大流的Too naive--结果事实证明从来都是我naive= =--明显是不行的--最大流可能有好几条--但不重边的更少--也许第一次Dijkstra找到的是最短路但不是最后不重边的最短路,然后就这么把边删了显然不对-- 所以我们还是言归正解吧--这道题就是ZOJ 2760的升级版吧--…
累了就要写题解,近期总是被虐到没脾气. 来回最短路问题貌似也能够用DP来搞.只是拿费用流还是非常方便的. 能够转化成求满流为2 的最小花费.一般做法为拆点,对于 i 拆为2*i 和 2*i+1.然后连一条流量为1(花费依据题意来定) 的边来控制每一个点仅仅能通过一次. 额外加入source和sink来控制满流为2. 代码都雷同,以HDU3376为例. #include <algorithm> #include <iostream> #include <cstring>…
思路:虽然是最短路专题里的,但也很难想到是最短路,如果能通过这些关系想到图论可能会有些思路.我们把X数组看做邻接矩阵,那么三个条件就转化为了:1.1的出度为1:2.n的入度为1:3.2~n-1的出度等于入度.C*X则是路径花费,最后求满足这些条件的路径的最少花费.满足这些条件的情况有两种:一是1到n的一条最短路径,二是1成自环,n成自环.最后找出两者最小值. 这里要注意下spfa的写法,因为需要成自环,所以dist[st]初始化为INF,保证成自环而非0:先让其他点入队. 代码: #includ…
A Walk Through the Forest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10172    Accepted Submission(s): 3701 Problem Description Jimmy experiences a lot of stress at work these days, especial…
Senior Pan fails in his discrete math exam again. So he asks Master ZKC to give him graph theory problems everyday. The task is simple : ZKC will give Pan a directed graph every time, and selects some nodes from that graph, you can calculate the mini…
题目大意: 从三维空间的(0,0,0)出发到(a-1,b-1,c-1),每移动一个都要时间加一,计算最短时间 根据六个方向,开个bfs,像spfa那样计算最短路径就行了,但是要1200多ms,也不知道有没有更好的方法 #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; ][][] , a , b , c; ][][] ,…
#include<stdio.h> #include<string.h> #include<math.h> #define inf 0x3fffffff #define N 200 #define eps 1e-10 #include<queue> using namespace std; struct node { int x,y; }ma[N]; struct nodee { int u,v,next; double w; }bian[N*N]; int…
A Walk Through the Forest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8850    Accepted Submission(s): 3267 Problem Description Jimmy experiences a lot of stress at work these days, especiall…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 123…