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

太仓市住房和城乡建设局规网站自学设计软件的免费网站

太仓市住房和城乡建设局规网站,自学设计软件的免费网站,万网怎样安装wordpress,怎么做微信推广和宣传题意#xff1a; n个学生要组成一个小组参加会议#xff08;可以不参加#xff09;#xff0c; 1.对于每两个朋友#xff08;x #xff0c;y)#xff0c;如果他们俩都参加会议#xff0c;该小组的友好价值将会增加 1#xff1b;如果其中只有一位参加会议#xff0c;…题意 n个学生要组成一个小组参加会议可以不参加 1.对于每两个朋友x y)如果他们俩都参加会议该小组的友好价值将会增加 1如果其中只有一位参加会议则该组的友好价值将降低 1。 3.如果n个学生参加会议对团队的友好价值将降低n. 题目 Professor Alex will organize students to attend an academic conference. Alex has n excellent students, and he decides to select some of them (possibly none) to attend the conference. They form a group. Some pairs of them are friends. The friendly value of the group is initially 0. For each couple of friends (x,y), if both of them attend the conference, the friendly value of the group will increase 1, and if only one of them attends the conference, the friendly value of the group will decrease 1. If k students attend the conference, the friendly value of the group will decrease k. Alex wants to make the group more friendly. Please output the maximum friendly value of the group. Input The first line of the input gives the number of test cases, T (1≤T≤104). T test cases follow. For each test case, the first line contains two integers n (1≤n≤3×105) and m (1≤m≤106), where n is the number of students and m is the number of couples of friends. Each of the following m lines contains two integers xi,yi (1≤xi,yi≤n,xi≠yi), representing student xi and student yi are friends. It guaranteed that unordered pairs (xi,yi) are distinct. The sum of n in all test cases doesn’t exceed 106, and the sum of m in all test cases doesn’t exceed 2×106. Output For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1), and y is the maximum friendly value of the group. Example Input 2 4 5 1 2 1 3 1 4 2 3 3 4 2 1 1 2 Output Case #1: 1 Case #2: 0 分析 1.由题意友好价值组群里的边数-点数 2.那么怎么求最大友好价值由于对于每两个朋友x y)如果他们俩都参加会议该小组的友好价值将会增加 1如果其中只有一位参加会议则该组的友好价值将降低 1所以我们用并查集直接找根节点遍历到最后这时就变成了一个个的组群我们只要判断这些组群是否参加会议即可当组群里的边数-点数0时不让其参加反之参加即可求得。 AC代码 #includebits/stdc.h using namespace std; const int M3e510; int t,n,m,k,ans; int f[M],a[M],b[M]; int getf(int x){if(f[x]x) return x;return f[x]getf(f[x]); } int main(){cint;k0;while(t--){cinnm;for(int i1;in;i){f[i]i;a[i]0;//记录边起始边个数为零。b[i]1;//记录点原始本身就为一个点。}for(int i1;im;i){int t1,t2;scanf(%d%d,t1,t2);int ugetf(t1);int vgetf(t2);if(uv) a[u];else {f[v]u;a[u]a[v]1;//因为最终怕判断的根节点判组群所以记录边和点只需要在根节点上即可。b[u]b[v];}}ans0;for(int i1;in;i){if(if[i]a[i]-b[i]0)ansa[i]-b[i];}printf(Case #%d: %d\n,k,ans);}return 0; }
http://wiki.neutronadmin.com/news/287163/

相关文章:

  • 网站建设容易吗阜新市建设小学网站
  • 模板网建站让别人做网站应注意什么
  • 政协网站法治建设版块游戏ui界面设计
  • 手机网站设计尺寸大小企业培训师资格证报考2022
  • 旅游网站开发周期深圳建筑工程交易服务主页
  • 扁平结构的网站做教育app的网站有哪些内容
  • 做网站 pc端与手机端兼容wordpress给会员发信
  • 大尺度做爰后入网站市场监督管理局是干什么的
  • 柬埔寨网站开发推广链接点击器
  • 免费域名申请哪个网站好棋牌推广
  • 江苏建设厅网站更新抖音广告投放平台官网
  • 福建建设资格管理中心网站互动平台是什么
  • 如何用图片做网站背景网站设计项目书
  • 淘宝店铺网站策划厦门企业网站制作
  • 把插钉机子拍下怎么做网站在哪里打广告效果最好
  • 滨州做企业网站张家口seo
  • 微网站手机制作时事新闻热点
  • 设计师找图网站怎么让网站能被百度到
  • 做网站的是外包公司吗南京h5 网站建设
  • 沧州网站建设 益志科技打开百度一下的网址
  • 遂川网站建设网站建设 题目
  • 嘉兴做网站多少钱建设微信网站制作
  • 温县住房与城乡建设局网站企业网站php开源系统
  • 网站怎么做留言长沙网站制作有哪些公司
  • 电子商务网站开发 pdf廊坊百度推广电话
  • 建立网站的优势wordpress图片美化
  • 做计算机题的网站营销型网站建设申请域名
  • 昆山教育云平台网站建设一级a行做爰片免费网站
  • 网站无搜索结果页面怎么做asp.net 网站建设
  • 饿了么网站做生鲜吗如何建立公司网站账号