题意: 从A点到B点的可达路径上的最大值的最小值
解题报告: 直接folyed ,改变松弛条件,两点的路径最小值必然为子路径上的最大值与其取min。
#define first f
#define second s
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn=305;
const int MOD=1e9+7;
const int inf=1e9+7;
const double PI=acos(-1);
const double e=2.718281828459;
int dist[maxn][maxn];
void floyed(int n)
{
for(int k=1;k<=n;k++){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
dist[i][j]=min(dist[i][j],max(dist[i][k],dist[k][j]));
}
}
}
}
int main()
{
int n,m,t,u,v,w;
scanf("%d%d%d",&n,&m,&t);
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){dist[i][j]=inf;}
}
for(int i=1;i<=m;i++){
scanf("%d%d%d",&u,&v,&w);
dist[u][v]=w;
}
floyed(n);
while(t--){
scanf("%d%d",&u,&v);
printf("%d\n",dist[u][v]==inf?-1:dist[u][v]);
}
return 0;
}