#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 110, M = 210, MM = 3000010;
int INF = 0x3f3f3f3f, mod = 100003;
ll LNF = 0x3f3f3f3f3f3f3f3f;
int n, m, k, T, S, D;
int g[N][N];
void floyd() {
for (int k = 1; k <= n; k++)
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
g[i][j] = max(g[i][j], g[i][k] + g[k][j]);
cout << g[1][n] << endl;
for (int i = 1; i <= n; i++)
if (g[1][i] + g[i][n] == g[1][n])cout << i << ' ';
}
int main() {
cin >> n >> m;
n++;
memset(g, -0x3f,sizeof(g));
for (int i = 1; i <= n; i++)g[i][i] = 0;
while (m--){
int a, b, x;
cin >> a >> b >> x;
g[a][b] = x;
}
floyd();
return 0;
}
标签:typedef,洛谷,P1476,int,题解,ll,long,floyd
From: https://blog.csdn.net/caihanang/article/details/143987662