Problem Statement
You are given a list of positive integers of length . Each integer represents the distance a trampoline will send you to the right. In particular, if you stand on the integer, then you will bounce to coordinate (this will keep happening until you bounce past all the trampolines).
You are asked to perform operations of the following form.
- Type 1: - Adjust the trampoline to bounce to the right. OR
- Type 2: - Determine the number of bounces before you make it past all the trampolines if you started on the trampoline.
After adjusting a trampoline, the trampoline will be adjusted permanently and all future operations should take that into account.
Input Statement
Your first line will contain and , representing the length of and the number of operations respectively. Your next line will contain space-separated integers representing the values of . Your next lines will contain or integers each, representing the operations described. If the line starts with a , then you will receive integers, , , and . If the line starts with a , then you will receive integers, and .
Output Statement
For each type 2 query, you should output a new line with an integer, representing the number of bounces before you make it past all the trampolines for the corresponding type 2 operation.
You should output these in the order the operations occurred in the input.
Constraints
- Queries are -indexed.
Sample Cases
Input 1
10 7
1 1 1 1 1 1 1 1 1 1
1 1 5
2 1
2 2
1 1 1
2 1
1 5 10000
2 3
Output 1
6
9
10
3
Explanation 1
The array is initially:
1 1 1 1 1 1 1 1 1 1
After performing 1 1 5
it becomes:
5 1 1 1 1 1 1 1 1 1
After querying 2 1
, we know it will take 6
jumps to exit the trampolines:
You start at 1
, jump to 6
, then to 7
, then to 8
, then to 9
, then to 10
, then past the trampolines.
After querying 2 2
we know that it will take 9
jumps, (jump 1
to the right every time starting from the trampoline).
The rest of the operations follow...
Comments