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

赣州晒房网门户网站网站地图怎么用

赣州晒房网门户网站,网站地图怎么用,做燕鲍翅的网站,免费h5网站模版2756 树上的路径 时间限制: 3 s    空间限制: 128000 KB    题目等级 : 大师 Master题目描述 Description给出一棵树#xff0c;求出最小的k#xff0c;使得#xff0c;且在树中存在路径P#xff0c;使得k S 且 k E. #xff08;k为路径P上的边的权值和求出最小的k使得且在树中存在路径P使得k S 且 k E. k为路径P上的边的权值和 输入描述 Input Description 第一行给出NSEN代表树的点数SE如题目描述一致 下面N-1行给出这棵树的相邻两个节点的边及其权值W 输出描述 Output Description 输出一个整数k表示存在路径P,并且路径上的权值和 KS , kE若无解输出-1 样例输入 Sample Input 5 10 40 2 4 80 2 3 57 1 2 16 2 5 49 样例输出 Sample Output 16 数据范围及提示 Data Size Hint 边权W10000, 保证答案在intlongint范围内,且|E-S|50 树上点的个数N30000    1 #includeiostream2 #includecstdio3 #includecstring4 #includealgorithm5 #define N 300096 using namespace std;7 int n,A,B,K,la,head[N],next[N1],ans2*1e9,size[N];8 int dep[N],maxson[N],root,tot,lls,num,ls[N];9 bool v[N]; 10 struct node 11 { 12 int fr,to,len; 13 }a[N1]; 14 void addedge(int x,int y,int z) 15 { 16 a[la].frx,a[la].toy,a[la].lenz; 17 next[la]head[x],head[x]la; 18 } 19 void get_root(int x,int from) 20 { 21 size[x]1; 22 maxson[x]0; 23 for(int ihead[x];i;inext[i]) 24 if (!v[ a[i].to ]a[i].to!from) 25 { 26 get_root(a[i].to,x); 27 size[x]size[ a[i].to ]; 28 maxson[x]max(maxson[x],size[ a[i].to ]); 29 } 30 maxson[x]max( maxson[x],tot-size[x] ); 31 if (!root||maxson[x]maxson[root]) rootx; 32 33 } 34 void get_dep(int x,int from) 35 { 36 for (int ihead[x];i;inext[i]) 37 if (!v[ a[i].to ]a[i].to!from) 38 { 39 ls[lls]dep[ a[i].to ]dep[x]a[i].len; 40 get_dep(a[i].to,x); 41 42 } 43 } 44 int get_num(int x,int jian) 45 { 46 int i,j,k,rt0; 47 ls[ lls1 ]dep[x]jian; 48 get_dep(x,0); 49 50 sort(ls1,lslls1); 51 for (i1,jlls;ills;i) 52 { 53 while (j1ls[i]ls[j]K) j--; 54 if (ji)rtj-i; 55 } 56 return rt; 57 } 58 void divide(int x) 59 { 60 numget_num(x,0); 61 v[x]1; 62 for (int ihead[x];i;inext[i]) 63 if (!v[ a[i].to ]) 64 { 65 num-get_num(a[i].to,a[i].len); 66 totsize[ a[i].to ]; 67 root0,get_root(a[i].to,0); 68 divide( root ); 69 } 70 } 71 int main() 72 { 73 int i,j,k,x,y,z,last; 74 scanf(%d%d%d,n,A,B); 75 for(i1;in;i) 76 { 77 scanf(%d%d%d,x,y,z); 78 addedge(x,y,z),addedge(y,x,z); 79 } 80 last1e9; 81 for(KA-1;KB;K) 82 { 83 num0; 84 memset(v,0,sizeof(v)); 85 totn,root0; 86 get_root(1,0); 87 divide(root); 88 if(numlast) 89 { 90 printf(%d\n,K); 91 return 0; 92 } 93 lastnum; 94 } 95 printf(-1\n); 96 }  备注引用自Codevs 题解 转载于:https://www.cnblogs.com/suishiguang/p/6172038.html
http://www.yutouwan.com/news/41371/

相关文章:

  • 律所网站建设要求书WordPress章节插件
  • 湖北省疾病预防控制中心官方网站做中东市场哪个网站合适
  • 温州开发网站公司做网站不赚钱了
  • 厦门建网站网址做网站需要
  • 网站建设费要摊销中国河北网站
  • 公司网站建设如何摊销做网站一年
  • WordPress网站动漫你在中国网重庆
  • 郑州哪些公司做网站比较好网店装修是什么意思
  • 什么网站可以做线上小游戏wordpress优质主题
  • 绥阳网站建设wordpress timeline
  • 网站建设数字的代码编写北京今天的最新发布消息
  • 建站之星破解版软件定制项目
  • 网站建设对宣传的意义超详细wordpress常用函数
  • 长春网站建设方案外包wordpress会员推广
  • 网站制作哪家好又便宜wordpress 白色主题
  • 济南建设网站的公司大型服装网站建设
  • 网站模板套餐安卓软件下载平台
  • 青海省制作网站专业购物最便宜的app
  • 网站维护运营好做吗网站建设板块
  • wap网站html5制作网赌app要多少钱
  • 民勤县建设局网站电子购物网站建设视频
  • 美妆网站设计模板2023年房地产最新消息
  • 手机网站建设wap厦门加盟网站建设
  • 能自己做网站接业务吗做百度网站优化多少钱
  • flash布局网站前端面试
  • 网站闭站保护微信公众号和网站建设
  • 关于网站建设的画册wordpress 文章章节
  • 东莞网站设计找谁网站不想续费
  • 网站的点击率怎么查WordPress是静态么
  • 台州企业网站PHP工具箱和WordPress