uoj#191. "Training Team Mutual Test 2016" Unknown

Source: Internet
Author: User

Test instructions: Maintain a sequence, each element is a two-dimensional vector, each time you can add an element behind or delete an element. Given P (x, y), ask what is the maximum value for the element $s_i$ in the [l,r] interval, $S _i \times p$.

To start with a simple equation like slope optimization, we need two points on the convex hull.

Learned a bit about this code http://uoj.ac/submission/69959

Use the segment tree to maintain the convex hull by subscript. So here's a question, if you follow the traditional notation, the complexity of merging once is with $o (interval length) $, which can result in a single insert/delete time complexity becoming $o (n) $, which is unacceptable.

Note that unlike normal line-segment trees, this only adds elements from behind, so an interval is only required to be filled, and then we can merge only after the interval has been filled, but the worst-case complexity of a single operation is still $o (n) $.

Consider what kind of operation makes the above complexity into $o (n) $: Insert Delete around the right end of a longer interval, whenever it is full, merge one, delete and insert one and then fill.

Instead of merging this interval when the interval is full, we wait until the next interval in the same layer fills up and merges the interval.

This way, once a node spends $o (L) $ for a combined time, at least $o (L) $ operations will make it merge again, so the averaging time complexity for each layer of a single operation is $o (1) $, a total $\log$ layer, and a single operation with an averaging time complexity of $o (\log N) $.

But in doing so, we don't necessarily use this node's information directly when a node is fully contained, because it hasn't been merged yet. We can only continue to recursion its son until we find the merged node to return the answer.

So how many intervals of information will be used altogether? We know that the segment tree interval query will fall on the $o (\log N) $ interval, because only the last interval of each layer is not merged, so this $o (\log N) $ range only the rightmost interval is placed on the $\log$ sub-range, the other is placed up to 2 sub-range, So the total will still fall on $o (\log N) $ range.

This problem requires two points on the convex hull, so a single query time complexity is $o (\log^2 N) $, Total time complexity $o (n\log^2 N) $, spatial complexity $o (n\log N) $.

"Notice"

If the length of the segment tree is the full power of 2, you can write the same way as the link at the beginning. If not, you need to write as follows (the leaf node cannot be merged).

"Code"

http://uoj.ac/submission/77261

The point on the back of the slope is the MLE. http://uoj.ac/submission/77384

uoj#191. "Training Team Mutual Test 2016" Unknown

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.