![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
最短路径
文章平均质量分 78
笑着走完自己的路
这个作者很懒,什么都没留下…
展开
-
最短路径小问题
struct Edge { int u, v, c, w, next; // c 是 长度,w 是 耗时};int dist[600];int node[600];int ans1[600];int top1;int res1, res2;bool vis[600];int pre[600];// 距离最短前提下的最少过点路径 void SPFA1(int s, int...原创 2017-03-19 19:14:50 · 558 阅读 · 0 评论 -
Codeforces 543B Destroying Roads 【暴力 SPFA】
B. Destroying Roadstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn some country there are exactly n cit原创 2015-11-10 20:40:13 · 1121 阅读 · 1 评论 -
hdoj 3468 Treasure Hunting 【BFS找所有最短路径上的点 + 最大流】
Treasure HuntingTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 1635 Accepted Submission(s): 429Problem DescriptionDo you li原创 2015-10-03 16:17:58 · 906 阅读 · 0 评论 -
Light oj 1019 - Brush (V)【最短路裸题】
1019 - Brush (V)PDF (English)StatisticsForumTime Limit: 2 second(s)Memory Limit: 32 MBTanvir returned home from the contest and got angry after seeing h原创 2015-08-20 18:35:01 · 813 阅读 · 0 评论 -
poj 3621 Sightseeing Cows 【最优比例环】 【0-1分数规划 + SPFA判负环】
Sightseeing CowsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8663 Accepted: 2900DescriptionFarmer John has decided to reward his cows for their hard原创 2015-09-02 17:09:23 · 476 阅读 · 0 评论 -
poj 2112 Optimal Milking 【最大流 简单题】 【floyd预处理最短路 + 二分 + 最大流】
Optimal MilkingTime Limit: 2000MS Memory Limit: 30000KTotal Submissions: 13910 Accepted: 5023Case Time Limit: 1000MSDescriptionFJ has moved his K (1 <= K <=原创 2015-08-06 18:24:05 · 753 阅读 · 0 评论 -
最短路径算法 dijkstra + floyd + spfa 【记录 总结】
问题:给定n个城市,这n个城市间有m条路,每条路长短不一,现让你求出从1到n的最短距离。 (1)dijkstra 算法:时间复杂度(N^2) 优点:效率高 缺点:不能求负权图 准备:用dist[]数组 记录起点到该节点的最短距离,用map[][]二维数组 记录每条边的权值即距离,用vis[]数组标记该点是否已查询过。 思路:每次原创 2015-06-12 13:23:10 · 1037 阅读 · 0 评论 -
hdoj 1869 六度分离 【判断任意点最短路是否小于等于7】
六度分离Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5473 Accepted Submission(s): 2220Problem Description1967年,美国著名的社会学家斯坦利·米尔原创 2015-07-24 23:09:42 · 430 阅读 · 0 评论 -
hdoj 5137 How Many Maos Does the Guanxi Worth 【枚举删点 + 最短路】
How Many Maos Does the Guanxi WorthTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 847 Accepted Submission(s): 322Problem Des原创 2015-08-15 16:37:06 · 542 阅读 · 0 评论 -
hdoj 1535 Invitation Cards 【最短路径SPFA】【正反向建边求单源最短路之和】
Invitation CardsTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2526 Accepted Submission(s): 1208Problem DescriptionIn the age原创 2015-07-22 12:14:05 · 658 阅读 · 0 评论 -
poj 3259 Wormholes 【spfa判断是否存在负环】
WormholesTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 34513 Accepted: 12602DescriptionWhile exploring his many farms, Farmer John has discovered a nu原创 2015-06-04 19:16:48 · 623 阅读 · 0 评论 -
poj 1062 昂贵的聘礼 【枚举最短路】
昂贵的聘礼Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 39266 Accepted: 11385Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要原创 2015-04-18 20:57:23 · 436 阅读 · 0 评论 -
hdoj 2112 HDU Today 【最短路】
HDU TodayTime Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16535 Accepted Submission(s): 3917Problem Description经过锦囊相助,海东集团终于度过了原创 2015-03-02 22:06:03 · 442 阅读 · 0 评论 -
hdoj 3339 In Action【SPFA + 0-1背包】
In ActionTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4772 Accepted Submission(s): 1572Problem DescriptionSince 1945, wh原创 2015-11-02 14:12:50 · 478 阅读 · 0 评论 -
hdoj 5521 Meeting 【优先队列 dijkstra】
MeetingTime Limit: 12000/6000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 328 Accepted Submission(s): 99Problem DescriptionBessie and her fri原创 2015-11-02 21:46:53 · 625 阅读 · 0 评论 -
Codeforces 301B Yaroslav and Time 【最短路】
题目链接:Codeforces 301B Yaroslav and Time原创 2016-03-24 22:18:38 · 436 阅读 · 0 评论 -
hdoj 1428 漫步校园 【dp + 最短路】
题目链接:hdoj 1428 漫步校园漫步校园Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3754 Accepted Submission(s): 1140Problem Description LL最近沉迷于A原创 2016-04-04 16:29:28 · 560 阅读 · 0 评论 -
Codeforces 400D Dima and Bacteria 【并查集 + 最短路】
题目链接:Codeforces 400D Dima and Bacteria原创 2016-03-21 23:56:37 · 425 阅读 · 0 评论 -
hdoj 5636 Shortest Path 【最短路】
题目链接:hdoj 5636 Shortest Path\原创 2016-03-08 12:38:23 · 350 阅读 · 0 评论 -
最短路之 路径记录 dijkstra + floyd + SPFA 【小笔记】
引子:我们在求解最短路的时候,有的时候需要输出路径,这里就介绍下路径记录及输出的一些方法。为了更好理解,提出一个问题:给出n个车站,m条单向路线以及 每条路线的信息即 起点终点和对应的花费(n与m同时为0表示结束),然后给出一系列的起点s和终点e(s和e同时为-1表示结束),让你求出最小花费并输出路径(假定给出的两点均是可达的)。(一) dijkstra算法实现:原创 2015-06-28 11:56:42 · 3756 阅读 · 0 评论 -
Poj 1603 Risk 【最短路】
题目链接:Poj 1603 RiskRisk is a board game in which several opposing players attempt to conquer the world. The gameboard consists of a world map broken up into hypothetical countries. During a player’s原创 2016-03-06 12:40:48 · 372 阅读 · 0 评论 -
hdoj 4411 Arrest 【费用流 + 最短路】
ArrestTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1731 Accepted Submission(s): 682Problem DescriptionThere are (N+1) citi原创 2016-01-31 19:36:36 · 530 阅读 · 0 评论 -
poj 2391 Ombrophobic Bovines 【floyd + 二分 + 拆点网络流】
Ombrophobic BovinesTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 16494 Accepted: 3601DescriptionFJ's cows really hate getting wet so much that the mer原创 2015-08-06 23:57:56 · 534 阅读 · 0 评论 -
hiho #1138 : Islands Travel 【最短路】
#1138 : Islands TravelTime Limit:10000msCase Time Limit:1000msMemory Limit:256MBDescriptionThere are N islands on a planet whose coordinates are (X1, Y1), (X2, Y2), (X3原创 2016-02-10 18:57:26 · 1182 阅读 · 1 评论 -
Codeforces 601A The Two Routes【最短路】
A. The Two Routestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Absurdistan, there are n towns (number原创 2015-12-03 16:36:21 · 596 阅读 · 0 评论 -
zzuoj 10413 && nyoj 1243 H.Radition Protection Wall 【几何 + 最短路】
10413: H.Radition Protection WallTime Limit: 3 Sec Memory Limit: 128 MBSubmit: 1 Solved: 1[Submit][Status][Web Board]DescriptionA military base in the tested nuclear weapons, an explos原创 2016-01-02 01:08:14 · 656 阅读 · 0 评论 -
hdoj 2485 Destroying the bus stations 【最小割 + 最短路】
Destroying the bus stationsTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2407 Accepted Submission(s): 779Problem Descriptio原创 2015-07-31 00:03:38 · 606 阅读 · 0 评论 -
zoj 2760 How Many Shortest Path 【最短路 + 最大流】 【求边不重复最短路径条数】
How Many Shortest PathTime Limit: 10 Seconds Memory Limit: 32768 KB Given a weighted directed graph, we define the shortest path as the path who has the smallest length among all the pa原创 2015-07-31 11:59:50 · 1109 阅读 · 0 评论 -
hdoj 3416 Marriage Match IV 【最大流 + 最短路】
Marriage Match IVTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2524 Accepted Submission(s): 755Problem DescriptionDo not si原创 2015-07-29 00:36:48 · 548 阅读 · 0 评论 -
poj 1847 Tram 【最短路 dijkstra + floyd + spfa】
TramTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 11183 Accepted: 4096DescriptionTram network in Zagreb consists of a number of intersections and ra原创 2015-06-04 23:28:06 · 874 阅读 · 0 评论 -
poj 2457 Part Acquisition 【spfa最短路 + STL路径输出】
Part AcquisitionTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3900 Accepted: 1689 Special JudgeDescriptionThe cows have been sent on a mission t原创 2015-06-25 20:58:21 · 849 阅读 · 0 评论 -
poj 2240 Arbitrage 【最短路】 【更新:用STL map处理字符串】
ArbitrageTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 17170 Accepted: 7248DescriptionArbitrage is the use of discrepancies in currency exchange rates t原创 2015-05-28 22:20:16 · 418 阅读 · 0 评论 -
hdoj 1599 find the mincost route 【最短路径floyd + 最小环】
find the mincost routeTime Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3043 Accepted Submission(s): 1223Problem Description杭州有N个原创 2015-06-02 17:44:49 · 547 阅读 · 0 评论 -
zzuoj 10408: C.最少换乘 【最短路 经典题目】
10408: C.最少换乘Time Limit: 2 Sec Memory Limit: 128 MBSubmit: 18 Solved: 5[Submit][Status][Web Board]Description欧洲某城是一个著名的旅游胜地,每年都有成千上万的人前来观光旅行。Dr. Kong决定利用暑假好好游览一番。。年轻人旅游不怕辛苦,不怕劳累,只要费用原创 2015-05-22 21:51:17 · 1522 阅读 · 0 评论 -
poj 2253 Frogger 【枚举+并查集 or 最短路】
FroggerTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 28514 Accepted: 9263DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly原创 2015-05-29 07:50:17 · 658 阅读 · 0 评论 -
poj 1125 Stockbroker Grapevine 【多源点最短路】
Stockbroker GrapevineTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 28840 Accepted: 15992DescriptionStockbrokers are known to overreact to rumours. You h原创 2015-05-28 15:37:29 · 389 阅读 · 0 评论 -
hdoj 1142 A Walk Through the Forest
A Walk Through the ForestTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6190 Accepted Submission(s): 2278Problem DescriptionJi原创 2015-03-05 21:37:30 · 762 阅读 · 2 评论 -
hdoj 3790 最短路径问题
最短路径问题Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15050 Accepted Submission(s): 4582Problem Description给你n个点,m条无向边,每条边都有长度d原创 2015-03-13 22:48:20 · 497 阅读 · 0 评论 -
hdoj 2680 Choose the best route
Choose the best routeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8080 Accepted Submission(s): 2662Problem DescriptionOne da原创 2015-03-08 16:07:20 · 428 阅读 · 0 评论 -
nyoj 115 城市平乱
城市平乱时间限制:1000 ms | 内存限制:65535 KB难度:4描述 南将军统领着N个部队,这N个部队分别驻扎在N个不同的城市。他在用这N个部队维护着M个城市的治安,这M个城市分别编号从1到M。现在,小工军师告诉南将军,第K号城市发生了暴乱,南将军从各个部队都派遣了一个分队沿最近路去往暴乱城市平乱。现在已知在任意两个城市之间的路行原创 2015-02-27 22:17:19 · 669 阅读 · 0 评论