不想写。

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cstdlib>
  5. #include<algorithm>
  6. #include<cmath>
  7. #include<map>
  8. #define pa pair<int,int>
  9. #define inf 1000000000
  10. #define ll long long
  11. using namespace std;
  12. inline int read()
  13. {
  14. int x=,f=;char ch=getchar();
  15. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  16. while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
  17. return x*f;
  18. }
  19. int n,cnt,ind,ans;
  20. int dfn[],low[],last[],size[];
  21. bool mark[];
  22. struct edge{int to,next;}e[];
  23. void insert(int u,int v)
  24. {
  25. e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
  26. e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
  27. }
  28. void tarjan(int x)
  29. {
  30.  
  31. dfn[x]=low[x]=++ind;
  32. size[x]=;
  33. int t=,res=n-;
  34. for(int i=last[x];i;i=e[i].next)
  35. if(!dfn[e[i].to])
  36. {
  37. tarjan(e[i].to);
  38. size[x]+=size[e[i].to];
  39. low[x]=min(low[x],low[e[i].to]);
  40. if(low[e[i].to]>=dfn[x])
  41. {
  42. t=max(t,size[e[i].to]);
  43. res-=size[e[i].to];
  44. }
  45. }
  46. else low[x]=min(low[x],dfn[e[i].to]);
  47. t=max(t,res);
  48. if(t<=n/)
  49. {
  50. ans++;
  51. mark[x]=;
  52. }
  53. }
  54. int main()
  55. {
  56. n=read();
  57. for(int i=;i<n;i++)
  58. {
  59. int u=read(),v=read();
  60. insert(u,v);
  61. }
  62. for(int i=;i<=n;i++)if(!dfn[i])tarjan(i);
  63. if(!ans)puts("NONE");
  64. else
  65. for(int i=;i<=n;i++)
  66. if(mark[i])printf("%d\n",i);
  67. return ;
  68. }

BZOJ 3391 Tree Cutting网络破坏的更多相关文章

  1. BZOJ 3391: [Usaco2004 Dec]Tree Cutting网络破坏( dfs )

    因为是棵树 , 所以直接 dfs 就好了... ---------------------------------------------------------------------------- ...

  2. 3391: [Usaco2004 Dec]Tree Cutting网络破坏

    3391: [Usaco2004 Dec]Tree Cutting网络破坏 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 76  Solved: 59[ ...

  3. BZOJ3391: [Usaco2004 Dec]Tree Cutting网络破坏

    3391: [Usaco2004 Dec]Tree Cutting网络破坏 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 47  Solved: 37[ ...

  4. 【BZOJ】3391: [Usaco2004 Dec]Tree Cutting网络破坏(dfs)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3391 显然判断每个点只需要判断子树是否小于等于n/2即可 那么我们虚拟一个根,然后计算每个子树的si ...

  5. BZOJ 3391 [Usaco2004 Dec]Tree Cutting网络破坏(树形DP)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3391 [题目大意] 给定一棵树,求分支size均不大于一半点数的点 [题解] 递归的同 ...

  6. BZOJ 3391 [Usaco2004 Dec]Tree Cutting网络破坏:dfs【无根树 节点分枝子树大小】

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3391 题意: 给你一棵无根树,求分支size均不大于一半点数的点. 题解: 假定1为根. ...

  7. BZOJ 3391: [Usaco2004 Dec]Tree Cutting网络破坏(搜索)

    这道直接遍历一遍求出每个点的子节点数目就行了= = CODE: #include<cstdio>#include<iostream>#include<algorithm& ...

  8. 【树形dp】Bzoj3391 [Usaco2004 Dec]Tree Cutting网络破坏

    Description     约翰意识到贝茜建设网络花费了他巨额的经费,就把她解雇了.贝茜很愤怒,打算狠狠报 复.她打算破坏刚建成的约翰的网络.    约翰的网络是树形的,连接着N(1≤N≤1000 ...

  9. 【枚举】bzoj3391 [Usaco2004 Dec]Tree Cutting网络破坏

    #include<cstdio> using namespace std; #define N 10001 int n; int v[N<<1],first[N],next[N ...

随机推荐

  1. 在线API文档

    http://www.ostools.net/apidocs A Ace akka2.0.2 Android Ant Apache CXF Apache HTTP服务器 ASM字节码操作 AutoCo ...

  2. C# 匿名方法 1027

    class Program { static void Main(string[] args) { SorAndShowFiles("Sorted by name", delega ...

  3. poj 2349(最小生成树应用)

    题目链接:http://poj.org/problem?id=2349 思路:由于有S个专门的通道,我们可以先求一次最小生成树,然后对于最小生成树上的边从大到小排序,前S-1条边用S-1个卫星通道连接 ...

  4. API 版本控制

    http://www.oschina.net/translate/introduction-to-web-api-versioning

  5. C++运算符重载——重载一元运算符

    0.重载一元操作符的方法 一元运算符即只需要一个操作用的运算符,如取地址运算符(&).复数(-).自减(--).自加(++)等. 运算符重载可以分为3种方式:类的非静态成员函数.类的友元函数. ...

  6. Tail-chaining(末尾连锁)中断说明

    [转载]http://lxdawn.blog.163.com/blog/static/173620990201273111337204/ Tail-chaining是指一个中断退出至下一个中断进入这段 ...

  7. Linux基础--文件与目录管理

    1.目录与路径 1)特殊目录 .   代表此层目录 ..  代表上一层目录 -   代表前一个工作目录 ~   代表『目前使用者身份』所在的家目录 ~account   代表account这个使用者的 ...

  8. iOS开发--动画(Animation)总结

    UIView的,翻转.旋转,偏移,翻页,缩放,取反的动画效果   翻转的动画 //开始动画 [UIView beginAnimations:@"doflip" context:ni ...

  9. jq的bind用法

    type,[data],function(eventObject)String,Object,Function type: 含有一个或多个事件类型的字符串,由空格分隔多个事件.比如"clic ...

  10. TWinControl与TControl的覆盖函数(TWinControl对TControl的10个消息覆盖函数,17个覆盖函数,私有虚函数仍可多态)

    手工找出来,对比一下,有助于VCL框架的理解.----------------------------------------------------------------------------- ...