#P3203. [HNOI2010] 弹飞绵羊

    ID: 2252 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2010各省省选湖南动态树Link-Cut Tree,LCT块状链表,块状数组,分块

[HNOI2010] 弹飞绵羊

Description

One day, Lostmonkey invented a super elastic device. To show off in front of his sheep friends, he invited a little sheep to play a game.

At the start of the game, Lostmonkey places nn devices along a straight line on the ground. Each device has an initial elasticity coefficient kik_i. When the sheep reaches the ii-th device, it will bounce forward kik_i steps, reaching the (i+ki)(i + k_i)-th device. If the (i+ki)(i + k_i)-th device does not exist, the sheep will be launched away.

The sheep wants to know, starting from the ii-th device, after how many bounces it will be launched away. To make the game more interesting, Lostmonkey may modify the elasticity coefficient of any device, and the coefficients are positive integers at all times.

Input Format

The first line contains an integer nn, indicating there are nn devices on the ground, numbered from 0n10 \sim n-1.

The next line contains nn positive integers, which are the initial elasticity coefficients of the nn devices in order.

The third line contains a positive integer mm, the number of operations. Each of the next mm lines contains at least two integers i,ji, j.

  • If i=1i = 1, you should output after how many bounces the sheep starting from device jj will be launched away.
  • If i=2i = 2, there will be one more positive integer kk, meaning the coefficient of device jj is updated to kk.

Output Format

For each operation with i=1i = 1, output one line containing a single integer representing the answer.

4
1 2 1 1
3
1 1
2 1 1
1 1
2
3

Hint

Constraints
For 20%20\% of the testdata, 1n,m1041 \le n, m \le 10^4.
For 100%100\% of the testdata, 1n2×1051 \le n \le 2 \times 10^5, 1m1051 \le m \le 10^5.

Translated by ChatGPT 5