#P3203. [HNOI2010] 弹飞绵羊
[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 devices along a straight line on the ground. Each device has an initial elasticity coefficient . When the sheep reaches the -th device, it will bounce forward steps, reaching the -th device. If the -th device does not exist, the sheep will be launched away.
The sheep wants to know, starting from the -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 , indicating there are devices on the ground, numbered from .
The next line contains positive integers, which are the initial elasticity coefficients of the devices in order.
The third line contains a positive integer , the number of operations. Each of the next lines contains at least two integers .
- If , you should output after how many bounces the sheep starting from device will be launched away.
- If , there will be one more positive integer , meaning the coefficient of device is updated to .
Output Format
For each operation with , 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 of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号