hdu 1596(Floyd 变形)】的更多相关文章

find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10450    Accepted Submission(s): 3694 Problem Description XX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1…
HDU.1596 find the safest road (Floyd) 题意分析 与普通的最短路不太相同,本题有些许的变化. 1. 要找到由i到j最安全的路,故在求解的时候要保证mp[i][j]尽量大,而不是尽量小. 2. 当mp[i][j] = 0的时候表示无法通过,而不是为无穷大的时候无法通过. 3. 路程求解过程中,安全系数是相乘的关系,不是按照普通路径的相加的关系. 4. 此题n^3的Floyd竟然能过,我惊了. 代码总览 #include <bits/stdc++.h> #def…
UVA - 10048 Audiophobia Consider yourself lucky! Consider yourself lucky to be still breathing and having fun participating in this contest. But we apprehend that many of your descendants may not have this luxury. For, as you know, we are the dweller…
Frogger DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sunscreen, he wants to avoid swimm…
http://acm.hdu.edu.cn/showproblem.php?pid=1596 find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6911    Accepted Submission(s): 2450 Problem Description XX星球有很多城市,每个城市之间有一条或…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1217 Arbitrage Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4430    Accepted Submission(s): 2013 Problem Description Arbitrage is the use of discr…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4034 Problem Description Everyone knows how to calculate the shortest path in a directed graph. In fact, the opposite problem is also easy. Given the length of shortest path between each pair of vertexe…
这道题怎么都是TLE,报警了,先放在这 http://acm.hdu.edu.cn/showproblem.php?pid=1596 #include <iostream> #include <iomanip> using namespace std; #define MAXVEX 1001 double matrix[MAXVEX][MAXVEX]; double D[MAXVEX]; int n; void Dijkstral(int v0) { ; double max; i…
Problem - 1596 变形最短路问题,给出邻接矩阵,要求求出给定点对间安全率最大值. 这题可以用dijkstra+heap来做.对于每一个查询,做一次dij即可. 代码如下: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <queue> using namespace std; ; double wt[N][N]…
http://acm.hdu.edu.cn/showproblem.php?pid=1596 #include <cstdio> #include <cstring> #include <algorithm> #define maxn 1001 using namespace std; double g[maxn][maxn]; int dis[maxn]; bool vis[maxn]; int n,a,b; void floyd() { ; k<=n; k++…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1869 题意分析:比较简单的最短路算法,最后只需判断最远两点距离是否大于7即可. /*六度分离 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4992 Accepted Submission(s): 2010 Problem Descriptio…
find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6973    Accepted Submission(s): 2469 Problem Description XX星球有非常多城市,每一个城市之间有一条或多条飞行通道,可是并非全部的路都是非常安全的,每一条路有一个安全系数s,s是在 0 和…
Rank Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1622    Accepted Submission(s): 625 Problem Description there are N ACMers in HDU team.ZJPCPC Sunny Cup 2007 is coming, and lcy want to selec…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31458    Accepted Submission(s): 14128 Problem Description Nowadays, a kind of chess game called “Super Jumping!…
变形课 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 18343    Accepted Submission(s): 6597 Problem Description 呃......变形课上Harry碰到了一点小麻烦,由于他并不像Hermione那样可以记住全部的咒语而任意的将一个棒球变成刺猬什么的,可是他发现了变形咒语的一个统一…
Frogger Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2253 Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone…
题目 这是用Dijsktra做的,稍加改动就好,1000ms..好水.. #define _CRT_SECURE_NO_WARNINGS #include<string.h> #include<stdio.h> #include<math.h> #include<algorithm> using namespace std; ; #define typec double const typec INF=0x3f3f3f3f;//防止后面溢出,这个不能太大 b…
思路: 我们先求一遍floyd,将各点的最短距离求出,然后将点按si的升序排序.dp[i][k]表示第i个点在第j时间所获得的最大效益,那么 dp[i][k]=max(dp[ i ][ k ]  ,  dp[ j ][ k-p[ i ].c-dis[ i ][ j ] ]+p[ i ].s);     dis[i][j]为i与j的最短路径. #include<iostream> #include<cstdio> #include<cstring> #include<…
题意: 给一个带权无向图,和一些询问,每次询问两个点之间最大权的最小路径. 分析: 紫书上的题解是错误的,应该是把原算法中的加号变成max即可.但推理过程还是类似的,如果理解了Floyd算法的话,这个应该也很容易理解. #include <cstdio> #include <algorithm> using namespace std; + ; ; int d[maxn][maxn]; int main() { //freopen("in.txt", "…
Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1630    Accepted Submission(s): 664 Problem Description 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,....VK,V1,那么必须满足K>2,…
Advanced Fruits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2358    Accepted Submission(s): 1201Special Judge Problem Description The company "21st Century Fruits" has specialized in cr…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30163    Accepted Submission(s): 13507 Problem Description Nowadays, a kind of chess game called “Super Jumping!…
find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7845    Accepted Submission(s): 2786 Problem Description XX星球有非常多城市.每一个城市之间有一条或多条飞行通道,可是并非全部的路都是非常安全的,每一条路有一个安全系数s,s是在 0 和…
XYZZY Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4421    Accepted Submission(s): 1252 Problem Description It has recently been discovered how to run open-source software on the Y-Crate gami…
一个人的旅行 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 29572    Accepted Submission(s): 10160 Problem Description 虽 然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能…
Friends Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less thank friends in common, they will become friends in several da…
题目大意: 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离. 思路: floyd算法模板题,这是一个牺牲空间换取时间的算法,本质是动态规划. AC代码: #include <iostream> #include <cstdio> #include <string.h> using namespace std; +; const int INF = 0x3f3f3f3f; int n, m; int mp[MX][MX]; void floyd()…
Floyd 输出路径 Sample Input50 3 22 -1 43 0 5 -1 -122 5 0 9 20-1 -1 9 0 44 -1 20 4 05 17 8 3 1 //收费1 3 //起点 终点3 52 4-1 -10 Sample OutputFrom 1 to 3 :Path: 1-->5-->4-->3Total cost : 21 From 3 to 5 :Path: 3-->4-->5Total cost : 16 From 2 to 4 :Path…
http://acm.hdu.edu.cn/showproblem.php?pid=5418 题目大意是城市的编号是1到n,给出m条路线,表示从a城市飞到b城市飞机要耗多少油,最后问飞机从1出发飞过所有的的城市最后再回到1最少耗多少油(数据保证至少存在一条这样的路), 要考虑的问题是满足全部连通和保证最短,最短好说,用弗洛伊德或者迪杰特斯拉,至于这个全部连通,一下子连想到了之前的状压搜索,用二进制保存是否经过所有的点,最后整理一下就是先 用弗洛伊德求出每从起点1到各个点的最短距离,然后哈密顿算法…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1114 Piggy-Bank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 32136    Accepted Submission(s): 15965 Problem Description Before ACM can do anythi…