"Is Rui OI 2019SC Day2"

<> Yes

<First update>


<Text>

Minute Osamu

Ordinary Divide and Conquer

Ordinary partition means divide and conquer algorithm for sequence or plane problems.

thought

The general idea of ​​partition refers to a sequence of plane problems or issues in some way divided into several sub-problems, the scale of the problem until the child is small enough, you can directly answer the question, the solution of the original problem and then get through the merger.

Generally speaking, we have a divided manner is a value associated with the subject feature, for example a maximum or minimum. And when using the feature value is not easy to divide, we can directly use the midpoint to divide, to ensure that the time complexity, and then try to calculate contributions.

Important examples and brief explanations

\ (1 \) selecting the maximum value of the sequence and all subranges: dividing using the maximum value, a maximum value calculated for each contribution can.

\ (2 \) selecting the maximum value of the minimum product sequence and all subranges: using the mid-point division, the discussion relative positional relationship of the minimum and maximum values and the midpoint, the contribution can be pre-calculated.

\ (3 \) seeking sequences for all subintervals \ (gcd \) the sum of: discovery \ (gcd \) no more than \ (log \) kinds of values, using the midpoint of the division, the segment contribution to computing.

Overall partition

Overall partition refers to the number of inquiries with the dynamic modification of the problem, the divide and conquer algorithm for all inquiries whole half of the answer.

thought

Overall partition will have multiple operations at the same time half the answer, then operated by classification to obtain sub-problems, then down recursive solution until the interval range is small enough, you can answer questions directly.

Its essence is half the answer as a whole, as well as sorting operation inquiry. When a problem also with modification operations, we need to modify the operation of the classification, which needs to be classified according to impact operations, we must also use the data structure records affected.

Important examples and brief explanations

\(1.\) k大数查询:对所有操作进行整体分治,对于一个询问,根据比\(mid\)值大的数的个数进行分类,对于一个添加操作,就看添加的数是否大于\(mid\)来计算影响,进行分类。

CDQ分治

\(CDQ\)分治指的是针对时间划分来计算修改操作影响的分治算法。

思想

形式化的,\(CDQ\)分治用来解决偏序问题,核心思想就是每次分治通过部分有序的特征化简偏序限制,回答询问,计算影响,再进行归并排序。其关键在于如何抽象出其偏序的关键字,来进行分治,还有影响以及询问的计算。

更一般的,\(CDQ\)分治可以在偏序问题中顶替一层数据结构,在动态问题中可以利用时间分治的技巧转动态为静态,是一种使用范围较广,比较广义的分治算法。

重要例题和简要题解

\(1.\) 陌上花开:三维偏序模板题,可以先排序一维,\(cdq\)分治维护一维,树状数组维护一维来统计答案。

\(2.\) 好朋友的题:矩阵和用二维前缀和拆一下,拆成\(4\)个不同贡献的询问,然后\(cdq\)分治维护修改的影响和计算答案即可。

点分治

点分治指的是树上利用重心作为划分点,进行统计的分治算法。

思想

点分治是对树上有关信息进行统计的算法,其划分在于每一次选取树的重心,统计有关重心的答案,然后再删除重心,将树分为若干个不同的子树,递归处理。

而点分治的关键在于如何快速对有关重心的答案进行统计,通常来说会分为两种方法:\(1.\) 用数据结构维护统计 \(2.\) 用单调性和尺取法统计。而在使用第二种方法的时候,又会涉及到同一棵子树内的答案,需要我们重新计算容斥掉,这就在于具体的处理。

重要例题和简要题解

\(1.\) 求所有边数小于等于\(L\)的链的长度之和:每一次以重心分治,用尺取法统计答案,用树状数组维护长度和,相同子树内的答案要容斥掉。


<后记>

Guess you like

Origin www.cnblogs.com/Parsnip/p/11267090.html