U678359 题解(英文版)
Consider how to solve this problem when we only have single-point modification.We have the following conclusions.(this part is premise conclusion) :
- Observation 1 :we only have
O(n) ordered pairs(l,r) that satisfy following conditions :(\max\limits_{i=l+1}^{r-1}a_i)<\min(a_l,a_r) .
Lets
Enumerate
- Observation 2 :Ordered pair
(l,r) that satisfy(\max\limits_{i=l+1}^{r-1}a_i)<\min(a_l,a_r) Form a bijection with all(l',r') ordered pairs that exist ax such thatl_x=l',r_x=r'(1\le x\le n)
The prove is easy , so we skip it.
Next, consider a type of dominance point pair.If we have a ordered pair
So we have some conclusions:
-
Observation 3 :We only have
O(n) of this kind of dominance point pair. -
Observation 4 :for a query
[l,r] ,consider to seta_{l-1} anda_{r+1} to+\infty .(this is an emporary assignment, to be changed back after the operation is completed ),so the answer isr-l+1-ans ,Whereans is the size of area who covered by dominance point pairs.
Lets
Then consider the changes to
- Observation 5 :For a modification to the interval
[l, r] , onlyS_l, S_{l+1} andT _r may add new elements, while the otherS_i andT_i may only delete some elements on the original basis.
Consider how to find these elements.Lets
Now we need to implement the function of refactoring
- Observation 6 :The problem can be transformed into finding the maximum
i that satisfiesa_i>s .Sinces becomes2s+\delta(\delta\ge 0) every timea_i>s is found, the maximum number ofO (\log V) rounds can be found.
This condition is not very simple, we need to strengthen it, so we have following conclusions:
- Observation 6 :The problem can be transformed into finding the maximum
i that satisfiesa_i-a_{i+1}>s .Sinces becomes2s+\delta(\delta\ge 0) every timea_i>s is found, the maximum number ofO (\log V) rounds can be found.
Note that
Therefore, we only need to find the appearance and departure time of each dominant point pair now, and consider dynamic maintenance.
So we can categorize and discuss the impact of interval modification on the dominance point pair
-
When
l \le L'\le R' \le r , it is equivalent to subtracting a number from the weights of these[l, r] . We have the conclusion that: -
Observation 8 :We can quickly find these
(l, r) based on Observation 6 and Observation 7, and brute force calculate the impact, which can be processed byO (n \log n \log V) . -
When
l\le L'\le r\le R' , it is equivalent to subtracting a number from the weights of these[l, r] . We have the conclusion that: -
Observation 9 :We can quickly find these
(l, r) based on Observation 6 and Observation 7, and brute force calculate the impact, which can be processed byO (n \log n \log V) .
The situation of
- When
L '\le l \le r \le R' , it is not possible to quickly find(l, r) that meets the requirements. This part can be achieved by using binary segmentation on the line segment tree and offline processing to achieveO (n \log n \log V) .
Then implement a scanning line method to achieve AC.
Therefore, we solved this problem within the complexity of
We just wrote the solution for U646757,Let's start the abnormal mode below.
For parallel universes in the
Since eating fish requires strict partial order in all dimensions, assuming there is a
-
Observation 10 :When
S eats a fish with>s_i in a certain dimension,S \gets 2S+\delta (\delta\ge 0) .Which means that the maximum number of such fish eaten is on the order ofO (m \log V) . -
Observation 11 : The conclusion derived from Observation 10 states that the number of dominance pair including a single point is on the order of
O(m \log V) . -
Observation 12 : A
(l, r) is a dominating point pair if and only if it is also a dominating point pair in one dimension, or if it satisfiesa_{l-1}>\sum\limits_ {i=l} ^ r (a_i)>a_ {r+1} ora_ {l-1}<\sum \limits_ {i=l} ^ r (a_i)<a_ {r+1} in one dimension. Prove is easy,so we skip it. -
Observation 13 :全局支配点对的总个数为
O(nm\log V) 量级。
证明:根据 Observation 12 推得。
接下来考虑多项式的问题,我们定义
-
Observation 14 :每次只有
S_{l},\cdots,S_{l+f(k)-1} 和T_r,\cdots,T_{r-f(k)+1} 需要重构,其他的都是在原有基础上删元素。 -
Observation 15 :定义
g(x)\gets x^k ,c(x)=g(x)-g(x-1)(x\ge 1) ,那么c(x) 呈递增态势,即g 的增长速度越来越快。
证明:考虑因式分解,
- Observation 16 :定义
h(x)=\frac{(\sum\limits_{i=1}^{x-1}i^m)}{x^m} ,则\forall x,h(x)\le h(x+1) 。
证明:
定义
- Observation 17 :如果
x^m<(\sum\limits_{i=1}^{x-1}i^m) ,那么(x+1)^m<(\sum\limits_{i=1}^x i^m) 。
证明:由 Observation 16 推得。
- Observation 18 :
f(x)\le 2^x+2 。
证明:考虑放缩,关于平均数对称 ,
- Observation 19 :
f(x) 在O(m\log m) 量级。
证明:因为每次加上一个大于其本身的数
接下来就是原来的算法了,注意到重点依然在寻找支配点对上,定义
那么我们有结论:
- Observation 20 : 一个
a_i>(\sum\limits_{j=i+1}^{T}a_j)+s 的一个必要不充分条件是c_{i,k}>s ,且a_i>s 的充分不必要条件是c_{i,k}>s ,因此找到c_{i,k}>s 的i 即可。
以下是强制在线且 Observation 20 即可。
定义
那么我们有结论:
- Observation 21 :
d_{i,j}\gets\sum\limits_{k=0}^{2^j-1}(-1)^{\operatorname{popcount}(k)}a_{i-k} 。
证明考虑归纳,略。
- Observation 22 :
d_{i,j}>s 时,\max\limits_{k=i-2^j+1}^i(a_k)\ge\frac{s}{2^j}
证明略。
那么注意到每次查找第一个
- Observation 23 : 令
g(x)=\log_{1+\frac{1}{x}}(2) ,那么g(x)\le f(x) 。
证明考虑随便差分一下就好了。
那么整体的复杂度就是