BUPT 201 tree Array

Source: Internet
Author: User

G, (BUPT 201)

Http://acm.bupt.edu.cn/onlinejudge/newoj/showProblem/show_problem.php? Problem_id = 201

 

There is an array a [] with a corresponding array C [], C [] with 0 or 1 stored, defining L (I, j) = min (A | I... J); Evaluate ans as the logarithm of all l (I, j) <K. If C [I] and C [J] are not equal, L (I, j) is infinite.

Two operations: 1. Output ans

0 I reverse C [I] value

Last thought: First, find the position with the closest I position to the right and the position with the value smaller than K, and then maintain the numbers of 0, 1 before and after each position (of course, you only need to maintain a value), and then each update only needs to add or subtract the value related to this element. This value can be O (1) * O (lgn) figured out...

No words to inspire ideas...

Be sure to use Longlong...

 

We need to have a solid foundation. We need to discuss more...

 

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.