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

网站建设的技术目标现代化专业群建设网站

网站建设的技术目标,现代化专业群建设网站,设计方案格式模板,中国建设银行官网站网点文章目录题目描述样例分析#xff1a;题意#xff1a;题解#xff1a;代码#xff1a;本题目传送题目树学是这个题的简易版#xff0c;也涉及换根问题#xff0c;可以先看看这个 树学 时间限制#xff1a;C/C 1秒#xff0c;其他语言2秒 空间限制#xff1a;C/C 32768… 文章目录题目描述样例分析题意题解代码本题目传送题目树学是这个题的简易版也涉及换根问题可以先看看这个 树学 时间限制C/C 1秒其他语言2秒 空间限制C/C 32768K其他语言65536K 64bit IO Format:%lld 题目描述 Trees are an important component of the natural landscape because of their prevention of erosion and the provision of a specific ather-sheltered ecosystem in and under their foliage. Trees have also been found to play an important role in producing oxygen and reducing carbon dioxide in the atmosphere, as well as moderating ground temperatures. They are also significant elements in landscaping and agriculture, both for their aesthetic appeal and their orchard crops (such as apples). Wood from trees is a common building material. Trees also play an intimate role in many of the world’s mythologies. Many scholars are interested in finding peculiar properties about trees, such as the center of a tree, tree counting, tree coloring. A(x) is one of such properties. A(x) (accumulation degree of node x) is defined as follows: Each edge of the tree has an positive capacity.The nodes with degree of one in the tree are named terminals.The flow of each edge can’t exceed its capacity.A(x) is the maximal flow that node x can flow to other terminal nodes. Since it may be hard to understand the definition, an example is showed below: 样例分析 A(1)115824 Details: 1-2 11 1-4-3 5 1-4-5 8(since 1-4 has capacity of 13) A(2)5611 Details: 2-1-4-3 5 2-1-4-5 6 A(3)5 Details: 3-4-5 5 A(4)1151026 Details: 4-1-2 11 4-3 5 4-5 10 A(5)10 Details: 5-4-1-2 10 The accumulation degree of a tree is the maximal accumulation degree among its nodes. Here your task is to find the accumulation degree of the given trees. 输入描述: The first line of the input is an integer T which indicates the number of test cases. The first line of each test case is a positive integer n. Each of the following n - 1 lines contains three integers x, y, z separated by spaces, representing there is an edge between node x and node y, and the capacity of the edge is z. Nodes are numbered from 1 to n. All the elements are nonnegative integers no more than 200000. You may assume that the test data are all tree metrics. 输出描述: For each test case, output the result on a single line. 示例1 输入 1 5 1 2 11 1 4 13 3 4 5 4 5 10输出 26题意 看看样例分析应该就明白了 每个节点都有流量求出最大流量是多少 题解 flow【i】表示i点的流量 一个点的流量是怎么来的如果jj是i的子节点的流量小于i与j边的容量flow【i】flow[j]如果大于两点之间的容量flow[i]i与j的流量 i与j的流量就是i与j的边权我们用edge[i][j]表示。 可以得到公式flow[i]∑min(flow[j],edge[i][j]) 因为i有可能有很多子节点所以加在一起 考虑完i之后我们来考虑换根 如图 我们将根从x换成y 题一中以x为根 x的流量来自于y子树2子树3 y的流量来自于子树1 图二中以y为根 x的流量来自子树2子树3 y的流量来自子树1x 我们发现换根后x的流量就没有了y的部分其他都还在此时x的流量就是原本的减去从y流向x的部分new[x]flow[ x ] - min ( flow[ y ] , edge[ x ] [ y ] ),这个new表示x新的流量 我们再看yy的流量多了从x流来的部分y的流量就是flow[y]min(new[x],edge[x][y])因为换根x的流量发生改变上一段所讲那流向y的是现在x的流量而不是换跟前的flow[x]. 换根前后图二中绿色区域没有发生改变也就是父节点改变影响不到子节点 还要注意叶子节点如果x从根变成叶子节点x的儿子只有y当y成为根节点之后x没有了儿子x的流量不是上面的公式而是变成了edge[x][y]因为没有子节点的流量流向x只有x与y的边权值也就是上面讲的式子使用条件是minxyx和y不能为0。 先求出x为根的流量然后依次换根求出最大值 代码 #include bits/stdc.h#define inf 0x7f typedef long long LL; using namespace std; const int maxn 2e5 3;int n;int head[maxn], cnt 0, d[maxn], deg[maxn], f[maxn]; struct edge{int x, y;int next;int w; }edge[maxn * 2];void init() { cnt 0;memset(head, -1, sizeof(head));memset(d, 0, sizeof(d));memset(deg, 0, sizeof(deg)); }void addedge(int x, int y, int w) {edge[cnt].x x;edge[cnt].y y;edge[cnt].w w;edge[cnt].next head[x];head[x] cnt;}void dfs(int root, int fa) {int ans 0;for(int i head[root]; i ! -1; i edge[i].next){int y edge[i].y;if(y fa){continue;}if(deg[y] 1){//如果y只有一个子节点y的流量只能是root与y的边权值 ans edge[i].w;}else{dfs(y, root);ans min(d[y], edge[i].w);}}d[root] ans return ; }//先求出节点x的流量 void dp(int x, int fa) {for(int i head[x]; i ! -1; i edge[i].next){int y edge[i].y;if(edge[i].y fa)continue;if(deg[x] 1){f[y] d[y] edge[i].w;}else{f[y] d[y] min(f[x] - min(d[y], edge[i].w), edge[i].w);//核心公式 }dp(y, x);} }//从x不断换根 int main() {int t;cint;int x, y, w;while(t--){init();//初始化 scanf(%d, n);for(int i 0; i n - 1; i){scanf(%d%d%d, x, y, w);addedge(x, y, w);//添边 addedge(y, x, w);//添边 deg[x];//deg用于判断这个点有几个子节点 deg[y];}int s 1;dfs(s, 0);//求x的流量 f[s] d[s];dp(s, 0);//不断换根 int ans 0;for(int i 1; i n; i){ans max(ans, f[i]);}printf(%d\n, ans);}return 0; }
http://www.huolong8.cn/news/278121/

相关文章:

  • 大连市建设工程老网站百度快照和做网站有关系吗
  • 网站内页可以做关键词优化吗怎么开发一个直播app
  • 建设部网站投诉核查企业名单南通网站建设方案开发
  • 网站服务器搭建XP如何给网店做推广
  • 烟台市未成年思想道德建设网站婚纱摄影网页设计
  • 手机wap网站建站系统网站301重定向 权重转移
  • 松山湖网站建设合肥网络推广优惠设想科技
  • 网站开发公司的选择网络营销与推广的概念
  • 电商网站前端源码wordpress 出名主题
  • 网站优化提升速度制作网页一般用什么来设计分割页面
  • 行业网站做不下去网站建站哪家公司好一点
  • 凡科网站建设平台好么大型网站开发经典框架
  • 优秀的定制网站建设制作商展示类网站开发费用
  • 网站建设版面分几页合适网站开发一般用的什么架构
  • 重庆市建设项目环境影响评价网站软件下载网站排行榜前十名
  • 做电力公司网站玛酷机器人少儿编程加盟
  • dw做的网站如何让文字换行dedecms视频网站模板
  • 如何建立网站数据库连接公众号登录手机版
  • 建设标准 免费下载网站企业logo设计合同
  • 保定企业免费建站wordpress 语言选择器
  • 企业网站建设成本费用有和wind一样做用网站
  • 做知识产权相关的网站宁波网站建设兼职
  • 网站建设什么打王思聪网站返利二维码怎么做
  • 还有用asp做网站的吗网站开发蓝云
  • 做返利网站怎麼建设工程合同通用条款
  • 电商网站平台有哪些大学生对校园网站建设的需求是什么
  • 公司网站建设计划邵阳找工作网站
  • 聚美优品网站怎么做的网络科技有限公司起名
  • 做教育app的网站有哪些最新域名ip地址
  • 南昌网站制作建站模板平台