Six Degrees of Separation

时间限制: 1 Sec  内存限制: 33 MB
[提交][状态][讨论版]

题目描述

In 1967, the famous sociologist Stanley Milgram proposed a "small world phenomenon (small world phenomenon)" the famous hypothesis,there are no more than 6 people among any two strangers,  only six people can link them together. therefore his theory is also called "six degrees of separation" theory (six degrees of separation). Although Milgram's theory has often come true, there are many sociologists of interest, but in the past 30 years, it has not been rigorous proof, just a legendary hypothesis.
Lele was quite interested in the theory, so he conducted a survey of N individuals . He has got the acquaintance between them. Now, please help him to verify whether the "six degree separation" is set up.

输入

This topic contains multiple sets of tests. Please handle the end of the file.
For each group of tests, the first line contains two integers N, M (0<N<100,0<M<200), representing the number of people, respectively, and the relationship between them.
Next, there are M lines, two integer A per line, B (0<=A, B<N), which means that people , numbered with A and numbered B, know each other.
In addition to this M group, the other two people are not acquainted with each other.
<n<100,0<m<200),�ֱ�����hdu������������Щ�˷ֱ�����0~n-1��)���Լ�����֮���Ĺ�ϵ��
<n)��ʾhdu������Ϊa�ͱ���b���˻�����ʶ��

输出

For each test, if the data is in accordance with the "six degrees of separation in line output" Yes ", otherwise output" No".

样例输入

8 7
0 1
1 2
2 3
3 4
4 5
5 6
6 7
8 8
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 0

样例输出

Yes
Yes

题目分析:图论,最短路径问题,大概意思是若两人之间认识的人大于6个输出No,否则输出Yes

代码如下:

# include<stdio.h>
# include<string.h>
int main(){int  n,m;while(~scanf("%d%d",&n,&m)){int a[105][105];memset(a,100,sizeof(a));int c1,c2;for(int i=0;i<m;i++){scanf("%d%d",&c1,&c2);a[c1][c2]=a[c2][c1]=1;      //将两人之间的距离设为 1 }for(int k=0;k<n;k++)        //克鲁斯卡尔算法 for(int i=0;i<n;i++)for(int j=0;j<n;j++){if(a[i][j]>a[i][k]+a[k][j])a[i][j]=a[i][k]+a[k][j];     }int k=1;for(int i=0;i<n;i++)           //判断两人i j 之间的距离是否大于6 {for(int j=0;j<n;j++){if(i!=j&&a[i][j]>6){k=0;break;}}}if(k) printf("Yes\n");else printf("No\n");}       return 0;
} 

XYNUOJ Six Degrees of Separation相关推荐

  1. 六度分离(Six Degrees of Separation)理论

    转自社会学吧 早在上个世纪60年代,美国著名社会心理学家米尔格伦(Stanley Milgram)就提出了"六级分隔"(Six Degrees of Separation)的理论, ...

  2. 【收藏】六度分隔、六度空间(Six Degrees of Separation)理论

    你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过六个人你就能够认识任何一个陌生人. 社会网络其实并不高深,它的理论基础正是"六度分隔".而社会性软件则是建立在真实的 ...

  3. POJ2139 Six Degrees of Cowvin Bacon【Floyd算法】

    Six Degrees of Cowvin Bacon Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9822 Accepted ...

  4. D - Six Degrees of Cowvin Bacon(最小路径)

    The cows have been making movies lately, so they are ready to play a variant of the famous game &quo ...

  5. xynuoj 2189 六度分离

    2189: 六度分离 时间限制: 1 Sec   内存限制: 32 MB 提交: 18   解决: 6 [ 提交][ 状态][ 讨论版] 题目描述 1967年,美国著名的社会学家斯坦利·米尔格兰姆提出 ...

  6. 苹果广告背景音乐大全【转】

    1.music every day 广告背景音乐(作者是rob simonsen,曲名red) 2.photo every day 广告背景音乐(作者是rob simonsen,曲名red) 3.ww ...

  7. Gossip协议详解

    起源 Gossip protocol 也叫 Epidemic Protocol (流行病协议),是基于流行病传播方式的节点或者进程之间信息交换的协议..Gossip protocol在1987年8月由 ...

  8. 7-7 六度空间 (30 分)(BFS遍历详解)(DFS最后一个点过不去)

    7-7 六度空间 (30 分) 一:题目: 六度空间"理论又称作"六度分隔(Six Degrees of Separation)"理论.这个理论可以通俗地阐述为:&quo ...

  9. 什么是社会性网络?什么是六度分隔理论?

    2007年05月23日 星期三 下午 03:13 根据维基百科的解释,"社会网络(Social Networking:SN)"是指个人之间的关系网络. 据一些不系统的分析,社会网络 ...

最新文章

  1. 循环矩阵傅里叶对角化
  2. js indexof用法indexOf()定义和用法
  3. Tomcat正常启动,可以访问其主页,却不能访问webapp中的项目的jsp文件
  4. oracle查询100到200数据,100分数据库查询语句(ORACLE 11g)
  5. 源码群友问:你这么多项目是怎么进行技术选型的?
  6. 如何改变Idea的背景
  7. nginx负载均衡与反向代理
  8. cordova 项目添加splash启动界面
  9. spring AspectJ的Execution表达式
  10. 查看网卡命令 uefi_大神教你开机进入UEFI模式的方法,非常简单
  11. 一个 redis 异常访问引发 oom 的案例分析
  12. xstatic图形连接linux,RHCE认证考试模拟题深入讲解:linux配置静态IP地址为:192.168.0.X!...
  13. linux下lampp(xampp)安装memcached扩展
  14. java三级 高级证书6_java web 学习 --第六天(Java三级考试)
  15. mobileterminal命令大全
  16. Win10获取管理员权限
  17. new Function的用法
  18. Discovery and auto register
  19. 解决Ubuntu DVD 用wubi 安装时候要重新下载镜像的笨方法
  20. awk、ruby计算总分排名,相同总分显示同一名次

热门文章

  1. Flash Player For Android
  2. 苹果最新消息_最新消息称苹果延期举行发布会:iPhone 12或将于10月推出
  3. 使用ftp服务上传文件时553报错的解决
  4. 尚硅谷和黑马java,全网首发!
  5. Reboot Restore Rx Pro v12.0 Build 2707937851 系统重启还原工具
  6. 实现文字后面加一条横线的效果
  7. java判断硬盘为固态硬盘_怎么看电脑是不是固态硬盘|查询电脑硬盘是HDD还是SSD的方法-系统城...
  8. 从Code Review 谈如何做技术
  9. dwg图纸的预览功能
  10. 基于LAB颜色空间的彩色图像分割