标签:
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5411 Accepted Submission(s): 2195
1 #include<stdio.h> 2 int map[100][100]; 3 int main(){ 4 int N,M,flot,p1,p2; 5 while(~scanf("%d%d",&N,&M)){ 6 for(int i=0;i<N;++i)for(int j=0;j<N;++j)if(i!=j)map[i][j]=map[j][i]=100;else map[i][j]=0; 7 while(M--){ 8 scanf("%d%d",&p1,&p2); 9 map[p1][p2]=map[p2][p1]=1; 10 } 11 for(int i=0;i<N;++i){ 12 for(int j=0;j<N;++j){ 13 for(int k=0;k<N;++k){ 14 map[j][k]=map[j][i]+map[i][k]<map[j][k]?map[j][i]+map[i][k]:map[j][k]; 15 } 16 } 17 }flot=1; 18 for(int i=0;i<N;++i){ 19 for(int j=0;j<N;++j){ 20 if(map[i][j]>7){//最开始的匹配多了一所以是大于7 21 flot=0;break; 22 } 23 } 24 if(!flot)break; 25 } 26 if(flot)puts("Yes"); 27 else puts("No"); 28 } 29 return 0; 30 }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4670798.html