Statistics of bzoj-1036-Tree count

Source: Internet
Author: User
Describe

There are n nodes on a tree, numbered 1 to N, each with a weight of W. We will ask you to do something about this tree in the following form: I. Change u t: Changing the weight of the node U to t ii. QMAX U V: asks for the maximum weight of the node on the path from point u to v. Qsum U V: asks for the weights and values of the nodes on the path from point u to v. Note: Nodes on the path from point u to v include U and V itself.

Analysis

Learn the problems that can be done by the tree chain split.

  • A query and an operation and a query maximum operation, the intermediate steps are different. Can write two functions, the return value is initialized when the time is not the same, qsum when initialized to 0, Qmax when the initialization when initialized to-inf.
  • If you want to call a segment tree without a tree link (such as a change in the subject, because it is a single point of modification), the change is not the x tid[x] new number of X. Because the number in the segment tree is re-edited.
Code

https://code.csdn.net/snippets/607983

The INF can be set 0x3f3f3f3f so that memset(0x3f) the initial value of the array is equal to. Better 0x3fffffff nature.--archon

A bunch of macros, write cooked very good. --archon

Statistics of bzoj-1036-Tree count

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.