hdu 1869 枚举+Dijstra
一点小变形就是了。。】 #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的更多相关文章
- ACM: HDU 1869 六度分离-Dijkstra算法
HDU 1869六度分离 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Descri ...
- hdu 4770(枚举 + dfs爆搜)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4770 思路:由于最多只有15个".",可以直接枚举放置的位置,然后判断是否能够全部 ...
- hdu 1869 (Floyd)
http://acm.hdu.edu.cn/showproblem.php?pid=1869 六度分离 Time Limit: 5000/1000 MS (Java/Others) Memory ...
- HDU 1869 六度分离
六度分离 http://acm.hdu.edu.cn/showproblem.php?pid=1869 Problem Description 1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一 ...
- hdu 3006 枚举集合能够产生的全部并集的集合
http://acm.hdu.edu.cn/showproblem.php? pid=3006 刚买的CHERRY键盘 手感真好 可惜不习惯 写代码老是打错.一个题写了一上午,都是各种按错键DEBUG ...
- hdu 5129 (枚举) The E-pang Palace
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5128. 给你n个点,问能否组成两个不相交的与坐标轴平行的矩形,能就输出两矩形的面积和,不能就输出一个字符串 ...
- hdu 4282 枚举,非二分
http://acm.hdu.edu.cn/showproblem.php?pid=4282 对于方程X^Z + Y^Z + XYZ = K,已知K求此方程解的个数,其中要求X<Y,Z>1 ...
- HDU 5225 枚举
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5225 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- hdu 1869 六度分离(最短路floyd)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1869 六度分离 Time Limit: 5000/1000 MS (Java/Others) M ...
随机推荐
- Windows系统配置Redis密码
1.首先停止Redis服务,直接关掉Redis或者打开任务管理器查看有没有redis-server进程,有的话选中并结束任务. 2.打开配置文件redis.windows.conf和redis.win ...
- c++ throw异常(学习)
#include <iostream>#include <stdio.h> using namespace std; void my_copy(const char* src_ ...
- Build Telemetry for Distributed Services之Elastic APM
官网地址:https://www.elastic.co/guide/en/apm/get-started/current/index.html Overview Elastic APM is an a ...
- 利用redis 分布式锁 解决集群环境下多次定时任务执行
定时任务: @Scheduled(cron= "0 39 3 * * *") public void getAllUnSignData(){ //检查任务锁,若其它节点的相同定时任 ...
- java+上传大文件
在Web应用系统开发中,文件上传和下载功能是非常常用的功能,今天来讲一下JavaWeb中的文件上传和下载功能的实现. 先说下要求: PC端全平台支持,要求支持Windows,Mac,Linux 支持所 ...
- VS自定义代码块Code Snippet
一 .简述 我们在开发当中,避免不了一些重复的开发工作,在你漫长的开发以及学习当中,你会发现有这么一部分代码是你时常会使用到的.我想这个工具也是针对这个原因出来的吧,它就是预先把你需要的这部分代码的 ...
- Linux Shell列出网络中所有的活跃主机
因为的的网段是 192.168.1.0/24 , 所以我只需遍历 192.168.1.1 到 192.168.1.255 之间的所有ip然后进行 ping 就可以了: test.sh: #!/bin/ ...
- c# 子窗体居中父窗体
1.设置CenterParent不管用.只好用代码控制. frmRunning_ = new FrmRunning(); frmRunning_.StartPosition = FormStartPo ...
- Lua中用table统一管理需要获取的unity物体
unity上的组件,可以用table统一管理 然后在初始化时候统一给table赋值,这样需要用到时候直接调用table中对应的key便可拿到对应的物体,省下了在脚本开头一堆声明的脚本,这样就不用声明这 ...
- 攻防世界MISC新手练习
0x01 this_is_flag 对!!!这就是flag 0x02 ext3 题目提示是Linux光盘,附件下载下来 在linux中挂载mount linux /mnt 找一下flagtrings ...