Flight Recently, Shua Shua had a big quarrel with his GF. He is so upset that he decides to take a trip to some other city to avoid meeting her. He will travel only by air and he can go to any city if there exists a flight and it can help him reduce…
Flight Time Limit : 20000/10000ms (Java/Other)   Memory Limit : 65535/65535K (Java/Other) Total Submission(s) : 5   Accepted Submission(s) : 1 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Recently, Shua Shua had a big…
Flight Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2014    Accepted Submission(s): 428 Problem Description Recently, Shua Shua had a big quarrel with his GF. He is so upset that he decides…
<题目链接> 题目大意: 现在给你一些点,这些点之间存在一些有向边,每条边都有对应的边权,有一次机会能够使某条边的边权变为原来的1/2,求从起点到终点的最短距离. 解题分析: 分层图最短路模板题,由于最多只能将一条边变成原来的1/2,所以我们在原来二维的图形上多加一层,由第一层到第二层的边代表该边边权为原边权的1/2.就按这种思想跑一遍Dijkstra即可. #include <cstdio> #include <cstring> #include <algori…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1726 题意: 给你一个无向图,求次短路. 题解: 两种方法. 方法一: 一遍spfa,在spfa内维护最短路dis和次短路sec. 分三种情况: (1)dis[now]可以更新dis[dest]. (2)dis[now]不能更新dis[dest],但dis[now]可以更新sec[dest]. (3)dis[now]不能更新dis[dest]和sec[dest],但sec[now]可以更…
C 国有 n 个大城市和 m 条道路,每条道路连接这 n 个城市中的某两个城市.任意两个城市之间最多只有一条道路直接相连.这 m 条道路中有一部分为单向通行的道路,一部分为双向通行的道路,双向通行的道路在统计条数时也计为 1 条.C 国幅员辽阔,各地的资源分布情况各不相同,这就导致了同一种商品在不同城市的价格不一定相同.但是,同一种商品在同一个城市的买入价和卖出价始终是相同的.商人阿龙来到 C 国旅游.当他得知同一种商品在不同城市的价格可能会不同这一信息之后,便决定在旅游的同时,利用商品在不同城…
HDU 1401 Solitaire 双向DFS 题意 给定一个\(8*8\)的棋盘,棋盘上有4个棋子.每一步操作可以把任意一个棋子移动到它周围四个方向上的空格子上,或者可以跳过它四个方向上的棋子(就像跳棋那样).给定初始状态和末状态,问能否在8步之内,从初始状态变换到末状态. 解题思路 这是是看的学长写的题解,很好,也算自己简单知道了双向BFS是什么情况了. 给定了初始状态和末状态,又有最多只能走8步的限制,所以我们很容易就可以想到进行双向BFS.但是一定要注意对冗余状态的剪枝.我们可以对这四…
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…
Recently, Shua Shua had a big quarrel with his GF. He is so upset that he decides to take a trip to some other city to avoid meeting her. He will travel only by air and he can go to any city if there exists a flight and it can help him reduce the tot…
Recently, Shua Shua had a big quarrel with his GF. He is so upset that he decides to take a trip to some other city to avoid meeting her. He will travel only by air and he can go to any city if there exists a flight and it can help him reduce the tot…