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

网站如何安装dedecms机械加工网站平台

网站如何安装dedecms,机械加工网站平台,广州海珠区有什么好玩的景点,wordpress编辑图片题意#xff1a;有n个谷仓有n-1条路连接#xff0c;问最少删除哪几个点才能使得删除点后得到的连通图的加点数不大于n/2. 分析#xff1a;求树的重心的变形题#xff0c;poj3107的简单版#xff0c;一遍dfs从叶子到根转移找出找到以每个节点为根的子树的结点数#xff0…题意有n个谷仓有n-1条路连接问最少删除哪几个点才能使得删除点后得到的连通图的加点数不大于n/2. 分析求树的重心的变形题poj3107的简单版一遍dfs从叶子到根转移找出找到以每个节点为根的子树的结点数f[u]{ f[v1]f[v2].....f[vn] }1;使得每棵子树节点数小于n/2并且父节点得那个连通图节点数小于等于n/2即n-f[u]n/2. 如果没有这样的点输出NONE Time limit     1000 ms Memory limit     65536 kB OS     Linux Source      USACO 2004 December Silver After Farmer John realized that Bessie had installed a tree-shaped network among his N (1 N 10,000) barns at an incredible cost, he sued Bessie to mitigate his losses.  Bessie, feeling vindictive, decided to sabotage Farmer Johns network by cutting power to one of the barns (thereby disrupting all the connections involving that barn). When Bessie does this, it breaks the network into smaller pieces, each of which retains full connectivity within itself. In order to be as disruptive as possible, Bessie wants to make sure that each of these pieces connects together no more than half the barns on FJ.  Please help Bessie determine all of the barns that would be suitable to disconnect. Input * Line 1: A single integer, N. The barns are numbered 1..N.  * Lines 2..N: Each line contains two integers X and Y and represents a connection between barns X and Y. Output * Lines 1..?: Each line contains a single integer, the number (from 1..N) of a barn whose removal splits the network into pieces each having at most half the original number of barns. Output the barns in increasing numerical order. If there are no suitable barns, the output should be a single line containing the word NONE. Sample Input 10 1 2 2 3 3 4 4 5 6 7 7 8 8 9 9 10 3 8 Sample Output 3 8 Hint INPUT DETAILS:  The set of connections in the input describes a tree: it connects all the barns together and contains no cycles.  OUTPUT DETAILS:  If barn 3 or barn 8 is removed, then the remaining network will have one piece consisting of 5 barns and two pieces containing 2 barns. If any other barn is removed then at least one of the remaining pieces has size at least 6 (which is more than half of the original number of barns, 5). 题意 给定一棵无向树节点为nn10000问删除那些节点可以使得新图中的每一个连通分支的节点数都不超过小于n/2 思路 树形dp任意定跟求出每个节点的儿子节点每个点为根的子树的节点数dp[i]然后考察每一个点如果n-dp[i]n/2以及以i的每一个儿子为根的子树的节点数都dp[u]n/2那么这个点就满足条件 /*题意给了一棵节点数为n的树的对应关系让判断去掉哪些 节点能使子数的大小小于等于n/2并将符合条件的节点从小到 大输出如果没有符合条件的节点则输出 “NONE”。 思路既然是让求哪些ji节点符合条件可以用邻接表构建一个 图然后用dfs找出每一个节点下连的图的dax大小些节点符合 条件将节点存入ans数组中。*/ #includecstdio #includecstring #includealgorithm #define N 10010 using namespace std; int n,s,e,first[N],book[N],ans[N]; struct node {int x,y; }que[2*N]; void add(int x,int y) //构建邻接表的函数 {que[e].xx;que[e].yfirst[y];first[y]e; } int dfs(int x) {int num0,sum0;book[x]1;int kfirst[x],flag0;while(k!-1){if(!book[que[k].x]){numdfs(que[k].x);sumnum;if(numn/2) //x节点下的图的大小超过了n/2不符合条件flag1;}kque[k].y;}if(n-sum-1n/2) //另一半是否小于等于n/2flag1;if(!flag)ans[s]x;return sum1; //加上自己 } int main() {while(~scanf(%d,n)){memset(first,-1,sizeof(first));//初始化memset(book,0,sizeof(book));se0; //有s个节点符合条件e用邻接表表示无向图的大小int a,b;for(int i1;in;i){scanf(%d%d,a,b);add(a,b); //构建邻接表add(b,a); //无向图}adfs(1); //从第一个点开始尝试if(s) //有s个节点符合条件{sort(ans,anss); //从小到大排序输出for(int i0;is;i)printf(%d\n,ans[i]);}else //没有符合条件的节点printf(NONE\n);} }
http://www.zqtcl.cn/news/228943/

相关文章:

  • 金融电子商务网站建设深圳有什么公司名称
  • 网站设计 术语wordpress 图片弹出
  • 哪些域名不能够做淘宝客网站查建设公司年度保证金网站
  • 自己怎样用手机建网站网站优化 北京
  • 深圳小语种网站建设深圳做网站哪个平台好
  • 给个高质量的网站做网站优化有前景吗
  • 外贸网站 源怎么利用互联网平台赚钱
  • 营销型网站建设平台wordpress 添加 常规
  • php主做哪种类型网站高端公司小程序建设
  • 网站域名301是什么意思在一呼百应上做网站行吗
  • 怎么做百度口碑网站郑州网站设计专家
  • 珠海网络公司网站建设邯郸铸邯网络信息科技有限公
  • 室内设计者联盟官网哈尔滨百度搜索排名优化
  • 网站公司打电话来说做网站天下信息网
  • 汕头制作企业网站百度舆情监测平台
  • 怎样跟网站做优化呢火狐搜索引擎
  • 如何做网站的维护和推广水利网站建设管理汇报
  • 申请网站就是做网站吗怎样凡科建设网站
  • 怎样做吓人网站网页制作成品图
  • 前端的网站重构怎么做做网站用的编程语言
  • 长沙网站设计多少钱一个月百度网盘app下载安装电脑版
  • 你好南京网站网站开发 seo
  • wordpress 文章延时加载seo软件系统
  • 网站建设与运营答案新浪网站首页
  • 网站怎么做关键词库如何建免费的企业网站
  • 跟老外做网站网络系统管理与维护机考
  • 网站推广方案范例江西南昌小程序开发
  • 烘焙类网站开发时代背景ppt素材模板免费下载
  • 如何制作多网页网站广州品牌seo推广
  • 域名怎么解析到网站什么是asp网站