样例题的话随便找个Floyd算法自己测一下吧,下面上封装后的Johnson板子:
(好啦…既然你们懒那我给你们找个吧。。AcWing.854)
链接:https://www.acwing.com/problem/content/description/856/
#include<bits/stdc++.h>
#define ll long long
#define white 0
#define black 1
#define grey 2
#define endl '\n'
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=1e3+5;
ll n,m,k;ll d[maxn],backup[maxn],h[maxn];
ll dis[maxn][maxn],dd[maxn],color[maxn],target[maxn][maxn];
struct node{
ll u,v,w;
}edge[25000];
void Bellman_ford(ll s){
memset(d,INF,sizeof(d));
d[s]=0;
for(ll i=1;i<=n+1;i++){
memcpy(backup,d,sizeof(d));
for(ll j