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

网站建设电话销售技巧沧州全网推网络科技有限公司

网站建设电话销售技巧,沧州全网推网络科技有限公司,网线制作图片,南宁百度seo价格题意#xff1a; 题意#xff1a; 有n个人#xff0c;m对人相互认识#xff1b; 问能否分成两个组#xff0c;组内任意两个人之间不认识#xff1b; 若不能#xff0c;则输出No#xff1b; 若能#xff0c;则相互认识的两个人一间房#xff0c;求最多需要几间房 题意 有n个人m对人相互认识 问能否分成两个组组内任意两个人之间不认识 若不能则输出No 若能则相互认识的两个人一间房求最多需要几间房 给出一些学生的认识情况比如A和B认识B和C认识但是A和C不一定认识。现在问能否将这些学生分成两个组并且每组中的学生互相不认识如果能分求出最大能匹配的学生对数。 题目 There are a group of students. Some of them may know each other, while others don’t. For example, A and B know each other, B and C know each other. But this may not imply that A and C know each other. Now you are given all pairs of students who know each other. Your task is to divide the students into two groups so that any two students in the same group don’t know each other.If this goal can be achieved, then arrange them into double rooms. Remember, only paris appearing in the previous given set can live in the same room, which means only known students can live in the same room. Calculate the maximum number of pairs that can be arranged into these double rooms. Input For each data set: The first line gives two integers, n and m(1n200), indicating there are n students and m pairs of students who know each other. The next m lines give such pairs. Proceed to the end of file. Output If these students cannot be divided into two groups, print “No”. Otherwise, print the maximum number of pairs that can be arranged in those rooms. Sample Input 4 4 1 2 1 3 1 4 2 3 6 5 1 2 1 3 1 4 2 5 3 6 Sample Output No 3 题解 1首先bfs判断是否是二分图然后求二分最大匹配。 2判断是否为二分图在无向图G中无向图G为二分图的充分必要条件是G至少有两个顶点,且当存在回路时其所有回路的长度均为偶数。回路就是环路也就是判断是否存在奇数环。如果存在奇数回路(回路中节点个数为奇数)则不是二分图。否则是二分图。 采用染色法bfs染色法是将一个点先染色然后把和它相邻的点染成不同的颜色如果遇到相邻点的颜色相同的情况就不是二分图 3 染色法判断回路奇偶性把相邻两点染成黑白两色如果相邻两点出现颜色相同则存在奇数回路。也就是非二分图。 4匹配的对数由于是两个相同的集合进行配对所以最后将结果除2 AC代码 #includestdio.h #includestring.h #includequeue #includealgorithm using namespace std; const int M2e210; int n,m,dp[M],book[M],e[M],map[M][M]; bool dfs()//先要判断能否分成两组使得每组内的人互不认识即判断是否为二分图 {memset(dp,-1,sizeof(dp));//染色数组-1为未染01则为两种不同颜色for(int i1; in; i){if(dp[i]!-1)continue;dp[i]0;queueintq;q.push(i);while(!q.empty()){int headq.front();q.pop();for(int j1; jn; j){if(!map[head][j])continue;if(dp[j]!-1dp[head]dp[j])//把相邻两点染成黑白两色如果相邻两点出现颜色相同则存在奇数回路。也就是非二分图。return false;else if(dp[j]-1){dp[j]!dp[head];q.push(j);}}}}return true; } bool math(int x)//匈牙利算法 {for(int i1; in; i)if(!book[i]map[x][i]){book[i]1;if(!e[i]||math(e[i])){e[i]x;return true;}}return false; } int main() {while(~scanf(%d%d,n,m)){memset(map,0,sizeof(map));for(int i1; im; i){int a,b;scanf(%d%d,a,b);map[a][b]map[b][a]1;}if(dfs()false){printf(No\n);continue;}int ans0;memset(e,0,sizeof(e));for(int i1; in; i){memset(book,0,sizeof(book));if(math(i))ans;}printf(%d\n,ans/2);//求对数除2}return 0; }
http://www.huolong8.cn/news/49195/

相关文章:

  • 上海网站建设-新闻动态南宁工程建设网站有哪些
  • 建站语言门户网站流程图
  • 网站后台报表统计系统Wordpress编辑工具
  • 潍坊做网站公司找外国女朋友的网站建设
  • 网站ie兼容性网站建设 虚拟化
  • 网站建设后台 手工上传网站制作与建设
  • 微网站建设讯息网站投资多少钱
  • 科技网站配色方案cms系统的优点
  • 创业网站模板做普通网站选择什么服务器
  • 怎么导入网站源码设计师网上接单被骗
  • 做视频网站挣钱吗简单网页模版
  • 织梦做的网站怎么传到网上工程承包合作协议书
  • 用ps做网站主页永清网站建设
  • 电子商务网站建设学什么建筑设计作品展示网站
  • 供求信息网站开发背景旅游网站首页设计图片
  • 建网站首选公司网上销售平台怎么做
  • 可以做一键拨号和导航的网站网页前端设计流程
  • 用微信微博网站来做睡眠经济seo关键词推广方式
  • 360网站建设搜索专业网站制作设
  • wordpress视屏站WordPress缩略图短代码
  • 破解wordpress网站密码提升学历机构
  • 做设计在哪个网站找图片大全杭州企业网站建设公司怎么样
  • wordpress中英文站点制作网站需要什么软件
  • 济南做网站找泉诺哈尔滨seo优化专注
  • 阿里云php网站建设教程帝舵手表官方网站
  • 宾馆做网站企业网站seo平台
  • 美丽乡村建设网站模板提供网站建设收益分录
  • 网站的搜索功能一般怎么做天元建设集团有限公司注册资金
  • 建设婚恋网站基本功能有哪些百度关键词规划师
  • 内蒙古城乡建设厅网站免费制作logo软件