And binary multiplication 10.2

Half is usually divided into two categories: binary search and binary answers.

T1

problem

A given number of columns \ (A [n-.... 1] \) , and now there are m inquiry, inquiry is larger than each of the minimum of x \ (a [i] \) values.

years

Offline: the number of columns and inquiries are sorted, then sweep it again.

Online: sorting, binary search.

T2

problem

Defines a section which is the mode number appears. To give a series \ (A [n-.... 1] \) , find all the values in the section, a large value of k is the number on the interval size excluding 1.

years

Provided answer ANS, the \ (ANS \ in [2, n-] \) . Provided the function \ (f [mid] \) is the value \ (\ le mid \) is a number one, the subject requires \ (F ( ans)> = K \) and \ (ans \) maximum. However, this function is not monotonically increasing in. so we have to find the answer ans by half.

The key is how the evaluation of f.
Too difficult

Small summary


T3

problem

[NOIP2011] intelligent quality inspector

years

W can be found, the smaller Y. In this case \ (y = f (w) \) is a monotonic function does not increase, so we can use dichotomy zero function is obtained.

T4

problem

[NOIP2015] skip stones

years

Binary jump distance, and then swept again if the distance between two stones smaller than a mid then to remove. Finally, the comparison with the number m of removing stone size.

T5

problem

For a string of query q times for inquiry \ ([l, r] \ ) length of the longest string of the palindrome. \ (N-, q \ Le 1E5 \) .

years

T6

problem

A \ (n \ times m \) of the trellis diagram, some of which have a lattice disorder, and some do not. Inquiry with T, each time a query sub-matrix, the greatest side length of the query is no obstacle within the square submatrix side length

years

ST two-dimensional table (kneeling).

Extended: \ (\ Theta (1) LCA \)


As shown, if we would like to request the LCA. 6 and 5, 2 and 5 we can see the intermediate depth in the depth of the smallest order is 2, LCA is 2. This process requires time and a DFS table ST.

Guess you like

Origin www.cnblogs.com/i-cookie/p/11617726.html