标签:des style blog http color os strong io
Description
Input
Output
Sample Input
Sample Output
#include <stdio.h> #include <string.h> #define ff 999999 int map[105][105]; int n; void flord() { int i, j, k; int flag=1; for(k=0; k<n; k++) { for(i=0; i<n; i++) { for(j=0; j<n; j++) { if(map[i][k]!=ff && map[k][j]!=ff && map[i][k]+map[k][j] < map[i][j] ) { map[i][j] = map[i][k] + map[k][j] ; } } } } for(i=0; i<n; i++) { for(j=0; j<n; j++) { if(map[i][j] > 7) { flag = 0; break; } } if(flag==0) break; } if(flag==1) printf("Yes\n"); else if(flag==0) printf("No\n"); } int main() { int m; int i, j; int u, v; while(scanf("%d %d", &n, &m)!=EOF) { for(i=0; i<n; i++) //初始化map { for(j=0; j<n; j++) { if(i==j) { map[i][j] = 0; } else { map[i][j] = ff; } } } for(i=0; i<m; i++) { scanf("%d %d", &u, &v ); map[u][v] = 1; map[v][u] = 1; } flord(); } return 0; }
标签:des style blog http color os strong io
原文地址:http://www.cnblogs.com/yspworld/p/3884968.html