跳到正文

题解

Solution of CF207B3 Military Trainings

tder约 2 分钟
原文
文章信息与版本

文章信息

发布
2024年11月22日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 2 分钟
题目
CF207B3

版本

  1. v1当前

你可以浏览这个题解的中文版本。

The images are hosted on Github, use an accelerator if it fails to load.

It is first easy to think of duplicating the sequence over and over again, breaking the ring into a chain, with each query i.e. querying a sub-segment answer.

Let fif_i be transferable from j=xj=x or j=yj=y, and consider a greedy.

where P(k)P(k) denotes the points from which fkf_k can be transferred, i.e. P(k)=[k−pk,k−1]P(k)=[k-p_k,k-1].

Since k−1∈P(k)k-1\in P(k) holds, we do not need to consider the contribution of the interval [i−pi,k−1][i-p_i,k-1]. Instead, [y−py,i−pi]⊆[x−px,i−pi][y-p_y,i-p_i]\subseteq[x-p_x,i-p_i], i.e., all points that can be transferred to yy can be transferred to xx, so it is sufficient to choose a transfer from xx. That is, it is not inferior to transfer from the smaller kk of k−pkk-p_k. Maintained in ST tables, complexity O(nlog⁡n+ans)\mathcal{O}(n\log n+\text{ans}).

You submited the code and found it accepted in the simulation game. You can use multiplicative preprocessing to figure out where you can jump 2n2^n steps, optimising to O(nlog⁡n)\mathcal{O}(n\log n).

原文