题目传送门 题目中文翻译: Description 桑给巴尔岛上的阿德尔顿镇有一家旅行社,它已决定为其客户提供除了许多其他名胜之外的景点.为了尽可能地从景点赚取收入,该机构已经接受了一个精明的决定:有必要找到在同一地点开始和结束的最短路线.你的任务是写一个找到这样的路线的程序. 镇内有N个交叉点,编号从1到N.同时有M条双向路,编号从1到M.两个交叉点可以由多条道路连接,但没有道路将交叉点与自己连接.每条观光环线都是一系列道路编号y_1,...,y_k,k> 2.道路y_i(1 <= i &l…
题目链接 #include <cstdio> #include <string> #include <cstring> #include <queue> #include <map> #include <algorithm> using namespace std; #define LL __int64 #define MOD 1000000007 #define INF 0xffffff ][],g[][],pre[][]; ];…
Floyd 最小环模板题 code /* floyd最小环,记录路径,时间复杂度O(n^3) 不能处理负环 */ #include <iostream> #include <cstring> using namespace std; const int INF = 109, maxn = 252645135; int g[INF][INF], dis[INF][INF], pre[INF][INF]; int ans[INF]; //pr[i][j]记录i到j最短路径的第一个点 i…
Sightseeing trip Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5590   Accepted: 2151   Special Judge Description There is a travel agency in Adelton town on Zanzibar island. It has decided to offer its clients, besides many other attra…
题目大意: 求一个最小环. 用Floyd 求最小环算法. #include <iostream> #include <cstdlib> #include <cstdio> #include <algorithm> #include <vector> #include <queue> #include <cmath> #include <cstring> using namespace std; #define…
Sightseeing trip Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:8588   Accepted:3224   Special Judge Description There is a travel agency in Adelton town on Zanzibar island. It has decided to offer its clients, besides many other attract…
Sightseeing Trip Time limit: 0.5 secondMemory limit: 64 MB There is a travel agency in Adelton town on Zanzibar island. It has decided to offer its clients, besides many other attractions, sightseeing the town. To earn as much as possible from this a…
题意:求最出小环,输出路径 #include <iostream> #include<cstdio> using namespace std; #define N 110 #define INF 0xffffff int map[N][N],n,m,dist[N][N],pre[N][N],path[N]; /* run this program using the console pauser or add your own getch, system("pause&q…
https://loj.ac/problem/10072 针对无向图 因为Floyd是按照结点的顺序更新最短路的,所以我们在更新最短路之前先找到一个连接点k,当前的点k肯定不存在于已存在的最短路f[i][j]的路径上,因为我们还没用这个k去更新最短路,相当于 (i -> k -> j -> j到i的最短路 -> i)这样一个环就找到了,接下来我们要记录路径,用path[i][j]表示在最短路i到j的路径上j的前一个结点,所以我们在更新最短路时也要更新这个点,原来的最短路是i -&g…
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <vector> using namespace std; typedef long long ll; + ; const int inf = 0x3f3f3f3f; int n, m, ans; int mp[maxn][maxn], dis[maxn][maxn], po…