标签:des style blog http color java os io
http://acm.hdu.edu.cn/showproblem.php?pid=1869
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4355 Accepted Submission(s): 1768
=====================================================
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <algorithm> #define MAXX 105 #define INF 1000000000 int d[MAXX][MAXX]; void Floyd(int n) { int i,j,k; for(k=0; k<n; k++) for(i=0; i<n; i++) for(j=0; j<n; j++) if(d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j]; } int main() { int n,m,i,j; while(scanf("%d%d",&n,&m)!=EOF) { int man1,man2; for(i=0; i<MAXX; i++) for(j=0; j<MAXX; j++) d[i][j] = INF; for(i=0; i<m; i++) { scanf("%d%d",&man1,&man2); d[man2][man1]=d[man1][man2]=1; } Floyd(n); bool flag = false; for(i=0; i<n; i++) { for(j=0; j<n; j++) { if(d[i][j] > 7) { flag = true; } } } if(flag) printf("No\n"); else printf("Yes\n"); } }
hdu 1869 (Floyd),布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/ccccnzb/p/3892429.html