HDU 6181 Two Paths】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6181 题意:给一个图,求出次短路. 解法:我之前的模板不能解决这种图,就是最短路和次短路相等的情况,证明这题数据还是水了.下来我修改了一下次短路的,就可以避免这种情况了.提供一个sample 4 4 (1,2,1)( 1, 3,1) (2 4,1) (3 ,4,1).这组的正确答案是2,算法就来看代码吧. #include <bits/stdc++.h> using namespace std;…
这是一道次短路的题 但是本题有两个坑 注意边权的范围,一定要在所有与距离有关的地方开 long long 本题所求的并不是次短路,而是与最短路不同的最短的路径,如果最短路不止一条,那么就输出最短路的长度 #include <iostream> #include <cstdio> #include <cstring> #include <cstring> #include <algorithm> #include <queue> usi…
题意:求次短路. 分析:关键是情况讨论. LL tmpd = x.d + e.dist; 以下情况对应的更新结果 1.tmpd(2) < 最短路(3) < 次短路(4)-------> 最短路 = 2,次短路 = 3 2.tmpd(2) = 最短路(2) < 次短路(3)-------> 最短路 = 2,次短路 = 2 3.最短路(2) < tmpd(3) < 次短路(4)-------> 最短路 = 2,次短路 = 3 #include<cstdio…
[链接]http://acm.hdu.edu.cn/showproblem.php?pid=6181 [题意] 让你求从1到n的次短路 [题解] 模板题; 因为点可以重复走; 则一定会有次短路. dijkstra算法+优先队列优化一下就好. [错的次数] 11+ [反思] 在写优先队列的时候,节点和路径长度写反了..应该节点写在后面才行的.. [代码] #include <bits/stdc++.h> using namespace std; #define lson l,m,rt<&l…
Two Paths Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 153428/153428 K (Java/Others) Total Submission(s): 2184 Accepted Submission(s): 856 Problem Description You are given a undirected graph with n nodes (numbered from 1 to n) and m edges. A…
题目链接 题意 给出n个点m条边的无向图,求次短路. 思路 和 POJ 2449 类似,只不过大小要开成long long. #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100011; const int INF = 0x3f; struct Edge { int v, nxt; LL w; } edge[N*2]; struct Node { int u; LL g, h;…
Two Paths Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 153428/153428 K (Java/Others)Total Submission(s): 525    Accepted Submission(s): 265 Problem Description You are given a undirected graph with n nodes (numbered from 1 to n) and m edge…
题目链接:hdu 4912 Paths on the tree 题目大意:给定一棵树,和若干个通道.要求尽量选出多的通道,而且两两通道不想交. 解题思路:用树链剖分求LCA,然后依据通道两端节点的LCA深度排序,从深度最大优先选.推断两个节点均没被标 记即为可选通道. 每次选完通道.将该通道LCA下面点所有标记. #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #includ…
How Many Paths Are There Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1010    Accepted Submission(s): 332 Problem Description   oooccc1 is a Software Engineer who has to ride to the work plac…
Sightseeing Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1023    Accepted Submission(s): 444 Problem Description Tour operator Your Personal Holiday organises guided bus trips across the Ben…