hdu 六度分离
http://acm.hdu.edu.cn/showproblem.php?pid=1869
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 500
using namespace std;
const int inf=<<; int g[maxn][maxn];
bool vis[maxn][maxn];
int n,m,a,b; int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
memset(vis,false,sizeof(vis));
for(int i=; i<n; i++)
{
for(int j=; j<n; j++)
{
if(i==j) g[i][j]=;
else g[i][j]=inf;
}
}
for(int i=; i<m; i++)
{
scanf("%d%d",&a,&b);
g[a][b]=g[b][a]=;
vis[a][b]=vis[b][a]=true;
}
for(int k=; k<n; k++)
{
for(int i=; i<n; i++)
{
for(int j=; j<n; j++)
{
if(g[i][j]>g[i][k]+g[k][j])
{
g[i][j]=g[i][k]+g[k][j];
}
}
}
}
bool flag=true;
for(int i=; i<n; i++)
{
for(int j=; j<n; j++)
{
if(g[i][j]>&&!vis[i][j]&&i!=j)
{
flag=false;
break;
}
}
if(!flag) break;
}
if(flag) printf("Yes\n");
else printf("No\n");
}
return ;
}
hdu 六度分离的更多相关文章
- hdu 六度分离 floyd
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1869 题意分析:比较简单的最短路算法,最后只需判断最远两点距离是否大于7即可. /*六度分离 Time ...
- ACM: HDU 1869 六度分离-Dijkstra算法
HDU 1869六度分离 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Descri ...
- HDU 1869 六度分离
六度分离 http://acm.hdu.edu.cn/showproblem.php?pid=1869 Problem Description 1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一 ...
- HDU ACM 1869 六度分离(Floyd)
六度分离 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDU 1869 六度分离 最短路
解题报告: 1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人, ...
- hdu 1869 六度分离(最短路floyd)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1869 六度分离 Time Limit: 5000/1000 MS (Java/Others) M ...
- HDU - 1869 六度分离 Floyd多源最短路
六度分离 1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即 ...
- Day4 - C - 六度分离 HDU - 1869
1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人 ...
- HDU 1869 六度分离【floyd】
题意:给出n个人,m个关系,问是否满足任意两个人之间的距离通过6个人就可以连接 用floyd就可以了,注意距离是大于7 #include<iostream> #include<cst ...
随机推荐
- Qt for Windows - Deployment和它的参数
http://doc.qt.io/qt-5/windows-deployment.html
- SmartBusinessDevFramework架构设计-2:结构图示
架构设计一览图 下图表示了本架构的设计草稿. 接下来 ,我们将逐步细述,各个模块之间的松散耦合关系. 核心的实现原理.敬请关注.
- centos下httpd 启动失败的解决办法
[root@csit yang]# service httpd start Starting httpd: [FA ...
- android使用Genymotion作为模拟器
Genymotion模拟器的好处自然不用多说,直接来说怎么用: (1)去官方网站下载:中文或英文的: http://www.genymotion.net/ http://www.genymotion. ...
- iOS - Usage of NSData
Reference link : https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/BinaryData/T ...
- hdu 5012 Dice
Problem Description There are 2 special dices on the table. On each face of the dice, a distinct num ...
- pyqt之倒计时例子
from PyQt4.Qt import *from PyQt4.QtCore import *from PyQt4.QtGui import *import sysdef main(): a= ...
- oracle插入特殊字符'&'问题
oracle转义字符开关:set define off / show define
- sdut2623--The number of steps(概率dp第一弹,求期望)
The number of steps Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描写叙述 Mary stands in a st ...
- 深入浅出理解iOS经常使用的正則表達式—基础篇[Foundation]
參考资料:cocoachina的zys475481075的文章 几个单词 Regular ['regjʊlə]adj. 定期的:有规律的 Expression[ɪk'spreʃ(ə)n; ek-] n ...