最短路
BYSora
这个作者很懒,什么都没留下…
展开
-
Lightoj1002——Country Roads(最短路变形)
I am going to my home. There are many cities and many bi-directional roads between them. The cities are numbered from 0 to n-1 and each road has a cost. There are m roads. You are given the number of m原创 2016-09-12 12:01:17 · 1314 阅读 · 0 评论 -
poj3268——Silver Cow Party(最短路+godv之力)
DescriptionOne cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (原创 2016-08-10 13:49:40 · 625 阅读 · 0 评论 -
poj1125——Stockbroker Grapevine(floyd算法)
DescriptionStockbrokers are known to overreact to rumours. You have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer the tactical edge in t原创 2016-05-04 11:10:37 · 576 阅读 · 0 评论 -
hdu3790——最短路径问题
Problem Description给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。 Input输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后一行是两个数 s,t;起点s,终点。n和m为原创 2016-03-30 16:59:20 · 358 阅读 · 0 评论 -
hdu2544——最短路(最短路径模板)
Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号原创 2016-02-04 17:04:35 · 447 阅读 · 0 评论 -
hdu1874——畅通工程续(最短路径)
Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。 每组数据第一行包含两个正整数N和M(0#incl原创 2016-02-03 20:56:36 · 438 阅读 · 0 评论 -
poj2387——Til the Cows Come Home(最短路径)
DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she want原创 2016-01-31 11:18:54 · 400 阅读 · 0 评论 -
蓝桥杯算法训练——最短路(SFPA)
问题描述 给定一个n个顶点,m条边的有向图(其中某些边权可能为负,但保证没有负环)。请你计算从1号点到其他点的最短路(顶点从1到n编号)。输入格式 第一行两个整数n, m。接下来的m行,每行有三个整数u, v, l,表示u到v有一条长度为l的边。输出格式 共n-1行,第i行表示1号点到i+1号点的最短路。 样例输入 3 3 1 2 -1 2 3 -1 3 1 2 样例输出 -1原创 2017-03-03 16:23:06 · 1311 阅读 · 0 评论 -
Lightoj1019——Brush (V)(最短路)
Tanvir returned home from the contest and got angry after seeing his room dusty. Who likes to see a dusty room after a brain storming programming contest? After checking a bit he found that there is no原创 2017-04-12 16:02:54 · 293 阅读 · 0 评论 -
Lightoj1174——Commandos(双向最短路)
A group of commandos were assigned a critical task. They are to destroy an enemy head quarter. The enemy head quarter consists of several buildings and the buildings are connected by roads. The command原创 2017-04-12 16:52:28 · 897 阅读 · 0 评论 -
poj1364——King(差分约束)
DescriptionOnce, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: “If my child was a son and if only he was a sound king.” After nine months her child was born,原创 2017-04-28 16:28:48 · 898 阅读 · 0 评论 -
poj1201——Intervals(差分约束)
DescriptionYou are given n closed, integer intervals [ai, bi] and n integers c1, …, cn. Write a program that: reads the number of intervals, their end points and integers c1, …, cn from the standar原创 2017-04-26 16:07:47 · 632 阅读 · 0 评论 -
poj1860——Currency Exchange(Eellman-Ford+权值为正的环路)
DescriptionSeveral currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies.原创 2016-08-10 18:21:50 · 1079 阅读 · 0 评论 -
poj3259——Wormholes(Eellman-Ford算法)
DescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a t原创 2016-08-12 10:46:58 · 1211 阅读 · 0 评论 -
hdu5876——Sparse Graph(补图的最短路)
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 and only if they are not adjacent in G. Now you are given an undirect原创 2016-09-11 10:31:16 · 929 阅读 · 1 评论 -
山东省第四届ACM省赛题——Proxy(dijistra+多条最短路)
题目描述 Because of the GFW (Great Firewall), we cannot directly visit many websites, such as Facebook, Twitter, YouTube, etc. But with the help of proxy and proxy server, we can easily get to these websi原创 2016-08-15 18:35:35 · 974 阅读 · 0 评论 -
poj1847——Tram(dijkstra)
DescriptionTram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to the one of the rails going out of the inte原创 2016-08-15 11:47:23 · 1226 阅读 · 0 评论 -
poj1062——昂贵的聘礼(dijkstra变形)
Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:”嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。”探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者原创 2016-08-14 15:49:34 · 780 阅读 · 2 评论 -
Lightoj1074——Extended Traffic(SPFA判断负环)
Description Dhaka city is getting crowded and noisy day by day. Certain roads always remain blocked in congestion. In order to convince people avoid shortest routes, and hence the crowded roads, to re原创 2016-08-13 17:20:11 · 725 阅读 · 0 评论 -
poj3169——Layout(差分约束+SPFA判断负环)
DescriptionLike everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1..N standing along a straight line waiting for feed. The cows a原创 2016-08-16 17:11:10 · 923 阅读 · 0 评论 -
poj3159——Candies(差分约束+SPFA堆栈)
DescriptionDuring the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s class a large bag of candies and had flymouse distribute the原创 2016-08-13 12:48:07 · 1014 阅读 · 0 评论 -
poj1511——Invitation Cards(SPFA+邻接表)
DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comed原创 2016-08-13 10:38:44 · 1268 阅读 · 0 评论 -
poj2240——Arbitrage(Bellman-Ford算法)
DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys原创 2016-08-12 19:51:38 · 1263 阅读 · 0 评论 -
poj3660——Cow Contest(判断绝对顺序)
DescriptionN (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating原创 2016-08-12 17:19:53 · 877 阅读 · 0 评论 -
poj1502——MPI Maelstrom(dijkstra算法)
DescriptionBIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee’s res原创 2016-08-12 16:28:58 · 1263 阅读 · 0 评论 -
poj2983——Is the Information Reliable?(差分约束+负权环路)
DescriptionThe galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line with N defense stations.原创 2017-04-26 16:56:02 · 925 阅读 · 0 评论