跳到正文

个人记录

U678359 题解(英文版)

int223约 16 分钟
原文
文章信息与版本

文章信息

收录
2026年5月1日
更新
2026年7月21日
篇幅
约 16 分钟

版本

  1. v2当前
  2. v1

∗+∞*\color{black}{+}\color{red}{\infty}

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)O(n) ordered pairs (l,r)(l,r) that satisfy following conditions : (max⁡i=l+1r−1ai)<min⁡(al,ar)(\max\limits_{i=l+1}^{r-1}a_i)<\min(a_l,a_r) .

Lets li=max⁡j<i,aj>ai(j),ri=min⁡j>i,aj>ai(j)l_i=\max\limits_{j<i,a_j>a_i}(j),r_i=\min\limits_{j>i,a_j>a_i}(j) .

Enumerate (l,r)(l,r) that (l,r)(l,r) is domination point pair .Lets w←arg max⁡i=l+1r−1(ai)w\gets \argmax\limits_{i=l+1}^{r-1}(a_i) . It’s easily to find that l=lw,r=rwl=l_w,r=r_w .So let’s be bolder.we have following conclusions:

  • Observation 2 :Ordered pair (l,r)(l,r) that satisfy (max⁡i=l+1r−1ai)<min⁡(al,ar)(\max\limits_{i=l+1}^{r-1}a_i)<\min(a_l,a_r) Form a bijection with all (l′,r′)(l',r') ordered pairs that exist a xx such that lx=l′,rx=r′(1≤x≤n)l_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 (l,r)(l,r) and a number ii that i∈(l,r)i\in(l,r) , (∑i=l+1r−1ai)<min⁡(al,ar)(\sum\limits_{i=l+1}^{r-1}a_i)<\min(a_l,a_r) .We can consider that fish named ii can’t eat fish named in [1,l][1,l] or [r,n][r,n] .

So we have some conclusions:

  • Observation 3 :We only have O(n)O(n) of this kind of dominance point pair.

  • Observation 4 :for a query [l,r][l,r] ,consider to set al−1a_{l-1} and ar+1a_{r+1} to +∞+\infty .(this is an emporary assignment, to be changed back after the operation is completed ),so the answer is r−l+1−ansr-l+1-ans ,Where ansans is the size of area who covered by dominance point pairs.

Lets Si=∑1≤j<i,(j,i) is dominance pair{j}S_i=\sum\limits_{1\le j<i,(j,i)\ is \ dominance \ pair}\{j\} , Ti=∑i<j≤n,(i,j) is dominance pair{j}T_i=\sum\limits_{i<j\le n,(i,j)\ is \ dominance \ pair}\{j\} 。

Then consider the changes to SS and TT in a single operation.We have the following conclusions:

  • Observation 5 :For a modification to the interval [l,r][l, r] , only Sl,Sl+1S_l, S_{l+1} and TrT _r may add new elements, while the other SiS_i and TiT_i may only delete some elements on the original basis.

Consider how to find these elements.Lets bi←ai−ai−1,di=ai−ai+1b_i\gets a_i-a_{i-1},d_i=a_i-a_{i+1} .It is easy to observe that each operation modifies the bb and dd arrays by adding a number (possibly 00 or a negative number) to a interval.

Now we need to implement the function of refactoring SiS_i and TiT_i . We only consider refactoring Si.It is easy to find that we need to implement O(log⁡n)O (\log n) to find the maximum ii that satisfies ai>(∑j=i+1xaj)a_i>(\sum\limits_{j=i+1}^{x}a_j ) , Define ss as the internal ∑a\sum a of the previous dominating point pair .Then we have following conclusions:

  • Observation 6 :The problem can be transformed into finding the maximum ii that satisfies ai>sa_i>s .Since ss becomes 2s+δ(δ≥0)2s+\delta(\delta\ge 0) every time ai>sa_i>s is found, the maximum number of O(log⁡V)O (\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 ii that satisfies ai−ai+1>sa_i-a_{i+1}>s .Since ss becomes 2s+δ(δ≥0)2s+\delta(\delta\ge 0) every time ai>sa_i>s is found, the maximum number of O(log⁡V)O (\log V) rounds can be found.

Note that ai−ai+1=dia_i-a_{i+1}=d_i, and each modification has an impact on dd in the form of adding or subtracting a number in the interval. Therefore, we can perform binary partitioning on the line segment tree, which can reconstruct SiS _i or TiT_i by O(nlog⁡Vlog⁡n)O(n\log V\log n) .

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 [l,r][l,r] , assuming that the modified interval is [L′,R′][L',R'] .

  • When l≤L′≤R′≤rl \le L'\le R' \le r , it is equivalent to subtracting a number from the weights of these [l,r][l, r] . We have the conclusion that:

  • Observation 8 :We can quickly find these (l,r)(l, r) based on Observation 6 and Observation 7, and brute force calculate the impact, which can be processed by O(nlog⁡nlog⁡V)O (n \log n \log V) .

  • When l≤L′≤r≤R′l\le L'\le r\le R' , it is equivalent to subtracting a number from the weights of these [l,r][l, r] . We have the conclusion that:

  • Observation 9 :We can quickly find these (l,r)(l, r) based on Observation 6 and Observation 7, and brute force calculate the impact, which can be processed by O(nlog⁡nlog⁡V)O (n \log n \log V) .

The situation of L′≤lL'\le l is still the same, but there is a special case:

  • When L′≤l≤r≤R′L '\le l \le r \le R' , it is not possible to quickly find (l,r)(l, r) that meets the requirements. This part can be achieved by using binary segmentation on the line segment tree and offline processing to achieve O(nlog⁡nlog⁡V)O (n \log n \log V) .

Then implement a scanning line method to achieve AC.

Therefore, we solved this problem within the complexity of O(nlog⁡nlog⁡V)O (n \log n \log V) .


We just wrote the solution for U646757,Let’s start the abnormal mode below.

For parallel universes in the mm dimension, we have the following conclusion:

Since eating fish requires strict partial order in all dimensions, assuming there is a (s1,⋯ ,sm)(s_1,\cdots,s_m) fish, we consider finding the first >si>s_i fish for each dimension. We define the property of a fish as S←∏1≤i≤m(si)S \gets \prod \limits_ {1\le i\le m}(s_i), so SS will not exceed VmV ^ m .

  • Observation 10 :When SS eats a fish with >si>s_i in a certain dimension, S←2S+δ(δ≥0)S \gets 2S+\delta (\delta\ge 0) .Which means that the maximum number of such fish eaten is on the order of O(mlog⁡V)O (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(mlog⁡V)O(m \log V) .

  • Observation 12 : A (l,r)(l, r) is a dominating point pair if and only if it is also a dominating point pair in one dimension, or if it satisfies al−1>∑i=lr(ai)>ar+1a_{l-1}>\sum\limits_ {i=l} ^ r (a_i)>a_ {r+1} or al−1<∑i=lr(ai)<ar+1a_ {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(nmlog⁡V)O(nm\log V) 量级。

证明:根据 Observation 12 推得。

接下来考虑多项式的问题,我们定义 f(x)←max⁡ix≥(∑j=1i−1jx)(i)+1f(x)\gets \max\limits_{i^x\ge (\sum\limits_{j=1}^{i-1} j^x)}(i)+1

  • Observation 14 :每次只有 Sl,⋯ ,Sl+f(k)−1S_{l},\cdots,S_{l+f(k)-1} 和 Tr,⋯ ,Tr−f(k)+1T_r,\cdots,T_{r-f(k)+1} 需要重构,其他的都是在原有基础上删元素。

  • Observation 15 :定义 g(x)←xkg(x)\gets x^k ,c(x)=g(x)−g(x−1)(x≥1)c(x)=g(x)-g(x-1)(x\ge 1) ,那么 c(x)c(x) 呈递增态势,即 gg 的增长速度越来越快。

证明:考虑因式分解, am−bm=(a−b)(∑i=0m−1aibm−1−i)a^m-b^m=(a-b)(\sum\limits_{i=0}^{m-1} a^ib^{m-1-i}) ,右边显然是递增的。

  • Observation 16 :定义 h(x)=(∑i=1x−1im)xmh(x)=\frac{(\sum\limits_{i=1}^{x-1}i^m)}{x^m} ,则 ∀x,h(x)≤h(x+1)\forall x,h(x)\le h(x+1) 。

证明:

定义 Sn=∑i=1n−1{in}S_n=\sum\limits_{i=1}^{n-1}\{\frac{i}{n}\} ,那么显然当 SnS_n 排序小于 Sn+1S_{n+1} 的时候结论成立,那么显然 Sn<Sn+1S_n<S_{n+1} ,证毕。

  • Observation 17 :如果 xm<(∑i=1x−1im)x^m<(\sum\limits_{i=1}^{x-1}i^m) ,那么 (x+1)m<(∑i=1xim)(x+1)^m<(\sum\limits_{i=1}^x i^m) 。

证明:由 Observation 16 推得。

  • Observation 18 :f(x)≤2x+2f(x)\le 2^x+2 。

证明:考虑放缩,关于平均数对称 ,(∑i=12x+1ix)≥(2x−1+1)x(2x+1)=(2x+2)x+(2x−1+1)x(\sum\limits_{i=1}^{2^x+1}i^x)\ge(2^{x-1}+1)^x(2^x+1)=(2^x+2)^x+(2^{x-1}+1)^x 。

  • Observation 19 :f(x)f(x) 在 O(mlog⁡m)O(m\log m) 量级。

证明:因为每次加上一个大于其本身的数 log⁡2(sum)\log_2(sum) 都会至少 +1+1 ,因此可以列不等式: mlog⁡x≤xm\log x\le x ,解得 xx 在 O(mlog⁡m)O(m\log m) 的量级内。

接下来就是原来的算法了,注意到重点依然在寻找支配点对上,定义 ci,j←max⁡(ci,j−1,0)−max⁡(ci−j,j−1,0)c_{i,j}\gets \max(c_{i,j-1},0)-\max(c_{i-j,j-1},0) , ci,0←aic_{i,0}\gets a_i 。

那么我们有结论:

  • Observation 20 : 一个 ai>(∑j=i+1Taj)+sa_i>(\sum\limits_{j=i+1}^{T}a_j)+s 的一个必要不充分条件是 ci,k>sc_{i,k}>s ,且 ai>sa_i>s 的充分不必要条件是 ci,k>sc_{i,k}>s ,因此找到 ci,k>sc_{i,k}>s 的 ii 即可。

以下是强制在线且 k≥2k\ge 2 的情况,k=1k=1 直接用 Observation 20 即可。

定义 di,j←di,j−1−di−2j−1,j−1d_{i,j}\gets d_{i,j-1}-d_{i-2^{j-1},j-1} , di,0←aid_{i,0}\gets a_i 。

那么我们有结论:

  • Observation 21 :di,j←∑k=02j−1(−1)popcount⁡(k)ai−kd_{i,j}\gets\sum\limits_{k=0}^{2^j-1}(-1)^{\operatorname{popcount}(k)}a_{i-k} 。

证明考虑归纳,略。

  • Observation 22 :di,j>sd_{i,j}>s 时, max⁡k=i−2j+1i(ak)≥s2j\max\limits_{k=i-2^j+1}^i(a_k)\ge\frac{s}{2^j}

证明略。

那么注意到每次查找第一个 di,k>sd_{i,k}>s 的 ii 后 ss 会变为 (1+12k)s+δ(δ≥0)(1+\frac{1}{2^k})s+\delta(\delta\ge 0) 。

  • Observation 23 : 令 g(x)=log⁡1+1x(2)g(x)=\log_{1+\frac{1}{x}}(2) ,那么 g(x)≤f(x)g(x)\le f(x) 。

证明考虑随便差分一下就好了。

那么整体的复杂度就是 O(nm24kk2log⁡klog⁡nlog⁡V)O(nm^24^kk^2\log k\log n\log V) ,做完了,暴力算法的复杂度是 O(nq(k+mlog⁡V))O(nq(k+m\log V)) 。

原文