标签:before maximum http poi eth ring smi cstring single
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 37069 | Accepted: 20612 |
Description
Input
Output
Sample Input
3 2 2 4 3 5 2 1 2 3 6 2 1 2 2 2 5 3 4 4 2 8 5 3 1 5 8 4 1 6 4 10 2 7 5 2 0 2 2 5 1 5 0
Sample Output
3 2 3 10
Source
#include<iostream> #include<cstdio> #include<queue> #include<algorithm> #include<cstring> #include<string> #include<stack> using namespace std; typedef long long LL; #define MAXN 109 #define N 100 #define INF 0x3f3f3f3f /* 所有点对其他点的最短路径中的最大值 最小的那一点! */ int n, k ,Min; int g[MAXN][MAXN], maxlen[MAXN]; 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] = min(g[i][j], g[i][k] + g[k][j]); } } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (j == i) continue; maxlen[i] = max(g[i][j], maxlen[i]); } if (maxlen[i] < Min) { Min = maxlen[i], k = i; } } } int main() { while (scanf("%d", &n), n) { memset(g, INF, sizeof(g)); memset(maxlen, -1, sizeof(maxlen)); int num,t,d; for (int i = 1; i <= n; i++) { scanf("%d", &num); while (num--) scanf("%d%d", &t, &d), g[i][t] = d; } k = -1, Min = INF; Floyd(); if (Min != INF) printf("%d %d\n", k, Min); else printf("disjoint\n"); } }
Stockbroker Grapevine POJ 1125 Floyd
标签:before maximum http poi eth ring smi cstring single
原文地址:http://www.cnblogs.com/joeylee97/p/7327044.html