I'm not LCT.
Qaqqqqqqq
DQS: "LCT a log runs slower than two log"
XCZHW: "I told you he ran slower than sqrt ..."
There are a lot of details about the problem ...
But the central idea is a sentence: "Record a point jump to the number of steps outside the block and the foothold"
NN, that's it.
Search is good to find ...
Just modify the same block in the same time.
void change (int x,int v)
{
num[x] = V;//ki
step[x] = 1;//jumps to block external steps
int mx = x/m,nxt = min (n,x + v);//Next C4/>NEXT[X] = Nxt;//cnbb just let me wa for half a day
if ((NXT)/M = = mx)
{
step[x] + = step[nxt];
NEXT[X] = next[nxt];
}
int r = x-1;
while ((r + 1)% M)
{
nxt = min (n,r + num[r]);
if (nxt/m = = mx)
{
Step[r] = step[nxt] + 1;
NEXT[R] = next[nxt];
}
r--;
}
return;
}
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <
Cmath> using namespace std;
const int MAXN = 200000 + 5;
int n,m,m;
int NUM[MAXN],NEXT[MAXN],STEP[MAXN];
void Init () {M = sqrt (n) + 1;
for (int i = n-1;i >= 0;i--) {int nxt = min (n,i + num[i]);
if (nxt/m = = i/m) {Step[i] = step[nxt] + 1;
Next[i] = next[nxt];
}} return;
} int ask (int x) {int ans = 0;
while (x < n) {ans + = step[x];
x = Next[x];
} return ans;
} void Change (int x,int v) {num[x] = V;
STEP[X] = 1;
int r = X-1,MX = x/m;
int nxt = min (n,x + v);
NEXT[X] = NXT;
if (NXT)/M = = mx) {step[x] + = STEP[NXT];
NEXT[X] = next[nxt];
} while ((R + 1)% M) {nxt = min (n,r + num[r]);
if (nxt/m = = mx) {Step[r] = step[nxt] + 1; Next[r] = Next[NXT];
} r--;
} return;
} int q,x,v;
int main () {scanf ("%d", &n);
for (int i = 0;i < N;i + +) {scanf ("%d", &num[i]);
Next[i] = min (n,i + num[i]);
Step[i] = 1;
} Step[n] = 0;
Next[n] = n + 1;
Init ();
scanf ("%d", &m);
for (int i = 1;i <= m;i + +) {scanf ("%d", &q);
Switch (q) {case 1:scanf ("%d", &x);p rintf ("%d\n", ask (x));
Case 2:scanf ("%d%d", &x,&v); change (X,V);
}} return 0; }