当前位置:网站首页>[learning notes] segment tree selection

[learning notes] segment tree selection

2022-07-07 13:09:00 Ants looking up at the starry sky

It's all violence

It's tiring to hit the line tree

Fibonotci

At first glance, this linear recurrence relationship is obviously matrix multiplication

The code ...

call .. Finished writing .

Two Permutations

Sequence hash ?

Rather, it is called segment tree maintenance sequence hash Worth a good question

analogy Permutation . The essence is to express complex states as an integer , This complexity is better .

Strange Addition

Obviously, segment tree maintenance dp .

Attention to detail . And don't be too heavy .

If the implementation is fine, you don't need to go to the leading zero . Slight seizure .

Strange Array

Worship wicton .

This question is not so obvious .

Consider from [i,i] Expand

Discussion on parity between partitions

Consider one < a i <a_i <ai The sum of > a i >a_i >ai The number of will offset

hold a i a_i ai as < a i <a_i <ai and > a i >a_i >ai Consider two cases twice , In this way, equal elements will not appear

take ≤ a i \leq a_i ai The number of 1 1 1 , > a i >a_i >ai The number of − 1 -1 1

Expand left and right respectively , Find the largest sub segment and a n s ans ans , Contribution: ⌊ a n s − 1 2 ⌋ \lfloor\frac{ans-1}{2}\rfloor 2ans1

take ≥ a i \geq a_i ai The number of 1 1 1 , < a i <a_i <ai The number of − 1 -1 1

Expand left and right respectively , Find the largest sub segment and a n s ans ans , Contribution: ⌊ a n s 2 ⌋ \lfloor\frac{ans}{2}\rfloor 2ans

The code ...

call .. Finished writing .

Phoenix and Memory

He who travels a hundred miles , Half 90 .

First, greedy for a group of solutions

If you want to get different sequences , There must be ( i , j ) (i,j) (i,j) ( i ≠ j ) (i\ne j) (i=j) bring l i ≤ a j ≤ r i l_i\leq a_j\leq r_i liajri also l j ≤ a i ≤ r j l_j\leq a_i\leq r_j ljairj

Perceptual understanding , If you change more on the greedy optimal plan , The plan is even worse .

Proof omitted .

原网站

版权声明
本文为[Ants looking up at the starry sky]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071059389078.html