Some data structure problems

Source: Internet
Author: User
Operations on a tree

3282 Tree

Delete Edge, double edge, single point of modification, ask for path XOR or.

1984: Under the Moon "Mao Jingxiu"

Path overlay, path increase, ask path Max

Simple Tree Profile

3306: The Tree

To support the root change, modify the point right, query the subtree minimum value

Do not change the root is a simple DFS sequence segment tree, the root of the word only need to know the current root and query the relationship between the point: if the query point is the son of the root, then direct inquiry can be, if the inquiry point is the root, then the output sum; otherwise the root must be in a subtree of the query point, So this time we have to query the original tree in addition to this subtrees tree all other points of Min, and this can be used in the line segment tree to ask two implementations ([1, start[son[x]]) ∪ (End[son[x]], n])

3083: A faraway country

As in the previous question, but to support path modification, it is only extended to the tree section.

Spoj Cot

Two-point path K-Small

The DFS sequence establishes a persistent weight segment tree for each point-to-root path, and then the LCA can be done.

3123: [Sdoi2013] Forest

Same as above, but with one more merge operation.

Each heuristic is merged and then violent reconstruction is possible.

Because a point is merged at most Logn times, each merge is Logn, so the total complexity nlog^2n

Some data structure problems

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.