UVA10048Audiophobia


//UVA10048Audiophobia
#include
#include
#include
using namespace std;
const int maxn = 100 + 5;
const int INF = 1000000000;
int G[maxn][maxn];
int main() {
	int m, n, q, kase = 0;
	while(scanf("%d%d%d", &n, &m, &q) == 3 && n) {
	    for(int i = 1; i <= n; i++) 
	        for(int j = 1; j <= n; j++) 
	        	if(i == j) G[i][j] = 0;
	        	else G[i][j] = G[j][i] = INF;//    
		for(int i = 0; i < m; i++) {
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			G[a][b] = G[b][a] = c;
		}
		for(int k = 1; k <= n; k++) 
		    for(int i = 1; i <= n; i++) 
		        for(int j = 1; j <= n; j++) 
		            G[i][j] = min(G[i][j], max(G[i][k], G[k][j]));
        if(kase++) printf("
"); printf("Case #%d
", kase); for(int i = 0; i < q; i++) { int u, v; scanf("%d%d", &u, &v); if(G[u][v] < INF) printf("%d
", G[u][v]); else printf("no path
"); } } return 0; } /* 7 9 3 1 2 50 1 3 60 2 4 120 2 5 90 3 6 50 4 6 80 4 7 70 5 7 40 6 7 140 1 7 2 6 6 2 7 6 3 1 2 50 1 3 60 2 4 120 3 6 50 4 6 80 5 7 40 7 5 1 7 2 4 0 0 0 */