2018/3/21 树链剖分入门题

这是一个关于树链剖分的题目,涉及对树形结构的操作。给定一棵有N个节点的树,每个边有初始成本,可以进行两种操作:改变边的成本或查询从节点a到节点b路径上的最大边成本。题目包含不超过20个测试用例,每个用例有N-1条边信息和一系列操作指令,最后以'DONE'结束。对于每个查询操作,需要返回路径上边的最大权值。
摘要由CSDN通过智能技术生成

You are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, 3...N-1.

We will ask you to perfrom some instructions of the following form:

  • CHANGE i ti : change the cost of the i-th edge to ti
    or
  • QUERY a b : ask for the maximum edge cost on the path from node a to node b

Input

The first line of input contains an integer t, the number of test cases (t <= 20). t test cases follow.

For each test case:

  • In the first line there is an integer N (N <&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值