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 ...
随机推荐
- 基于docker的sqli-labs搭建
一键代码: curl https://files-cdn.cnblogs.com/files/kagari/sqli-labs.sh|bash https://files-cdn.cnblogs.co ...
- ubuntu下安装g++
主要来自ubuntu中文社区http://www.ubuntu.org.cn/support/documentation/doc/VMware 首选,确认你已经安装了build-essential程序 ...
- flutter 中 List 和 Map 的用法
list集合 在Dart中,数组是List对象,因此大多数人只是将它们称为List.以下是一个简单的Dart的List: 创建一个int类型的list List list = [10, 7, 23]; ...
- 前端知识点回顾——Reactjs
React.js 编写react需要安装的三个开发环境下的模块 babel 解析JSX react 实现ui用户界面 react-dom 处理dom JSX:在JavaScript里面写html代码( ...
- android studio gradle国内代理设置
android studio在开始都各项目之前都会遇到 gradle 的同步,而在同步过程中很多依赖下载特别慢甚至出现无法现在的情况,有的时候等的时间特别长,甚至要一天,关键是等了大半天之后突然报错, ...
- amm与tmpfs和swap
/dev/shm对Oracle 11g的影响: ORACLE 从11g版本开始,引入了一个自动内存管理(Automatic Memory Management)特性,该特性需要更多的共享内存(/dev ...
- 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 ...
- MobileNet V2深入理解
转载:https://zhuanlan.zhihu.com/p/33075914 MobileNet V2 论文初读 转载:https://blog.csdn.net/wfei101/article/ ...
- 图像分割-Mask Scoring R-CNN
转载:https://zhuanlan.zhihu.com/p/58291808 论文链接:https://arxiv.org/abs/1903.00241 代码链接:https://github.c ...
- CentOS7使用rpm安装mysql5.7
第一步.前往mysql官网下载所需的版本 Mysql5.7的rpm包下载地址为https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-1. ...