一点小变形就是了。。】

#include<iostream>
#include<cstdio>
#define maxn 201
#define inf 999999
using namespace std;
int
n,m,mapp[maxn][maxn],dis[maxn],vis[maxn];
void
init()
{

fill(dis,dis+n,inf);
fill(vis,vis+n,);
}

void
dij(int s)
{

dis[s]=;
while
()
{

int
v=-;
for
(int i=;i<n;i++) if(!vis[i]&&(v==-||dis[i]<dis[v])) v=i;
if
(v==-) break;//如果
vis[v]=;
for
(int i=;i<n;i++) dis[i]=min(dis[i],dis[v]+mapp[v][i]);
}
}

int
main()
{

cin.sync_with_stdio(false);
while
(cin>>n>>m)
{

for
(int i=;i<n;i++)
{

for
(int j=;j<n;j++)
{

if
(i==j) mapp[i][j]=;
else
mapp[i][j]=inf;
}
}

while
(m--)
{

int
a,b;
cin>>a>>b;
mapp[a][b]=mapp[b][a]=;
}

int
flag=;
for
(int i=;i<n;i++)
{

init();
if
(flag) break;
dij(i);
for
(int j=;j<n;j++) if(dis[j]>=)
{

flag=;
break
;
}
}

if
(flag) cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}

return
;
}

hdu 1869 枚举+Dijstra的更多相关文章

  1. ACM: HDU 1869 六度分离-Dijkstra算法

    HDU 1869六度分离 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Descri ...

  2. hdu 4770(枚举 + dfs爆搜)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4770 思路:由于最多只有15个".",可以直接枚举放置的位置,然后判断是否能够全部 ...

  3. hdu 1869 (Floyd)

    http://acm.hdu.edu.cn/showproblem.php?pid=1869 六度分离 Time Limit: 5000/1000 MS (Java/Others)    Memory ...

  4. HDU 1869 六度分离

    六度分离 http://acm.hdu.edu.cn/showproblem.php?pid=1869 Problem Description 1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一 ...

  5. hdu 3006 枚举集合能够产生的全部并集的集合

    http://acm.hdu.edu.cn/showproblem.php? pid=3006 刚买的CHERRY键盘 手感真好 可惜不习惯 写代码老是打错.一个题写了一上午,都是各种按错键DEBUG ...

  6. hdu 5129 (枚举) The E-pang Palace

    题目;http://acm.hdu.edu.cn/showproblem.php?pid=5128. 给你n个点,问能否组成两个不相交的与坐标轴平行的矩形,能就输出两矩形的面积和,不能就输出一个字符串 ...

  7. hdu 4282 枚举,非二分

    http://acm.hdu.edu.cn/showproblem.php?pid=4282 对于方程X^Z + Y^Z + XYZ = K,已知K求此方程解的个数,其中要求X<Y,Z>1 ...

  8. HDU 5225 枚举

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5225 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

  9. hdu 1869 六度分离(最短路floyd)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1869 六度分离 Time Limit: 5000/1000 MS (Java/Others)    M ...

随机推荐

  1. centos7的网络配置参考

    <鸟哥的Linux私房菜>中的相关介绍和配置:http://linux.vbird.org/linux_basic/0610hardware.php 修改链接(connection)的名字 ...

  2. ubuntu hadoop安装

    参考: https://wangchangchung.github.io/2017/09/28/Ubuntu-16-04%E4%B8%8A%E5%AE%89%E8%A3%85Hadoop%E5%B9% ...

  3. 转:C++何时调用构造函数,何时调用析构函数

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/wjf1997/article/detai ...

  4. django models 关系

    1.一对多/多对一 class Entry(models.Model): name=models.CharField(max_length=50) def __str__(self): return ...

  5. ccf 201803-3 URL映射(python)

    使用正则表达式 import re import collections n, m = list(map(int, input().split())) arr = ['']*(m+n) for i i ...

  6. android在点击EditText的时候始终不弹出软件键盘

    场景描述:正常情况下,当点击EditText时,软键盘会弹出来.现在的要求是当点击EditText时,弹日期选择对话框,选择的结果显示在EditText上.若不处理,当点击EditText时,软键盘和 ...

  7. jack语言编译器的实现过程

    目录: 1, 背景介绍

  8. JAVA 基础编程练习题47 【程序 47 打印星号】

    47 [程序 47 打印星号] 题目:读取 7 个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*. package cskaoyan; public class cskaoyan47 { ...

  9. 跨域form下载方式 批量下载

    downloadFileForm:function(fid) { var url = "https://file.xxxx.com/fileDownload.do"; var in ...

  10. ASP.NET关于UEditor简单配置和错误修正

    UEditor配置版本为:ueditor1_3_6-utf8-net,放置目录为:/UEditor 一./UEditor/ueditor.config.js文件需要设置: 1.URL修改为:var U ...