当前位置: 首页 > wzjs >正文

开发app怎么盈利seo网站推广专员

开发app怎么盈利,seo网站推广专员,wordpress hover,龙岗营销网站建设公司题目描述 给定一个无向图和其中的所有边&#xff0c;判断这个图是否所有顶点都是连通的。 输入 每组数据的第一行是两个整数 n 和 m&#xff08;0<n<1000&#xff09;。n 表示图的顶点数目&#xff0c;m 表示图中边的数目。如果 n 为 0 表示输入结束。随后有 m 行数据…
题目描述

给定一个无向图和其中的所有边,判断这个图是否所有顶点都是连通的。

输入

每组数据的第一行是两个整数 n 和 m(0<=n<=1000)。n 表示图的顶点数目,m 表示图中边的数目。如果 n 为 0 表示输入结束。随后有 m 行数据,每行有两个值 x 和 y(0<x, y <=n),表示顶点 x 和 y 相连,顶点的编号从 1 开始计算。输入不保证这些边是否重复。

输出

对于每组输入数据,如果所有顶点都是连通的,输出"YES",否则输出"NO"。

样例输
4 3
4 3
1 2
1 3
5 7
3 5
2 3
1 3
3 2
2 5
3 4
4 1
7 3
6 2
3 1
5 6
0 0
样例输出
YES
YES
NO

 分析:和问题A差不多的思路,用并查集检查是否只有一个集合。当然也可以用BFS或者DFS检查是否只有一个连通分量。

#include<algorithm>
#include <iostream>
#include  <cstdlib>
#include  <cstring>
#include   <string>
#include   <vector>
#include   <cstdio>
#include    <queue>
#include    <stack>
#include    <ctime>
#include    <cmath>
#include      <map>
#include      <set>
#define INF 0xffffffff
#define db1(x) cout<<#x<<"="<<(x)<<endl
#define db2(x,y) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<endl
#define db3(x,y,z) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<endl
#define db4(x,y,z,r) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<", "<<#r<<"="<<(r)<<endl
#define db5(x,y,z,r,w) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<", "<<#r<<"="<<(r)<<", "<<#w<<"="<<(w)<<endl
using namespace std;int findFather(int father[],int x)
{if(father[x]==-1)return -1;int a=x;while(father[x]!=x){x=father[x];}while(a!=father[a]){int z=a;a=father[a],father[z]=x;}return x;
}void Union(int a,int b,int father[])
{int fa=findFather(father,a),fb=findFather(father,b);if(fa!=fb)father[fa]=father[fb];return;
}int father[1000010];
bool isroot[1000010];int main(void)
{#ifdef testfreopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);clock_t start=clock();#endif //testint n,m;while(scanf("%d%d",&n,&m),n){int father[1010],isroot[1010]={0};for(int i=1;i<=n;++i)father[i]=i;int a,b;for(int i=0;i<m;++i){scanf("%d%d",&a,&b);if(findFather(father,a)==-1)father[a]=a;if(findFather(father,b)==-1)father[b]=b;Union(a,b,father);}for(int i=1;i<=n;++i){if(father[i]==i)isroot[i]=1;}int ans=0;for(int i=0;i<1010;++i)if(isroot[i])ans++;if(ans==1)printf("YES\n");else printf("NO\n");}#ifdef testclockid_t end=clock();double endtime=(double)(end-start)/CLOCKS_PER_SEC;printf("\n\n\n\n\n");cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位#endif //testreturn 0;
}

http://www.dtcms.com/wzjs/1928.html

相关文章:

  • 郑州网站设计培训百度新闻头条新闻
  • 网站假设公司排名网络营销项目策划
  • 双鸭山网站开发设计网站
  • 做教师知识网站有哪些内容谷歌seo怎么优化
  • jsp简述网站开发流程图爱站网关键词长尾挖掘
  • 毕业设计做网站选题国家域名注册服务网
  • wordpress禁止缩略图百度点击优化
  • 上海市城乡建设和管理委员会网站怎样推广公司的网站
  • 国内房地产设计网站建设重庆发布的最新消息今天
  • 高品质的网站开发公电商运营一天都干啥
  • 建网站找那家企业好互联网营销工具
  • 高手优化网站优化seo厂家
  • 360浏览器怎么创建网页seo关键词如何布局
  • 做网站遇到竞争对手怎么办百度软件商店下载安装
  • 移动端页面长沙网站托管seo优化公司
  • 郑州疫情严重程度百度seo在哪里
  • 影视网站建设方案北京seo推广外包
  • 网站建设与管理维护 李建青专业培训seo的机构
  • 淘宝1688批发网官网免费发seo外链平台
  • 网站教人做核能灯互联网营销师怎么考
  • 长沙行业网站建设考研培训机构排名
  • 网站开发接口文档模板seo网站优化助理
  • 做检测设备的网站有哪些百度站长seo
  • 1核1g可以做几个网站手机端怎么刷排名
  • 做伊瑞尔竞技场的网站小程序定制
  • 可信赖的南昌网站制作百度seo关键词优化软件
  • 页面跳转的方式有哪些微软优化大师
  • 易优cms和织梦cms的区别湖南企业seo优化
  • 制作微网站公司seo关键词排名技巧
  • 做网站需要准备资料网站优化seo怎么做