Jump Game


Problem Statement

You are given a list of positive integers aa of length nn. Each integer represents the distance a trampoline will send you to the right. In particular, if you stand on the ithi^{th} integer, then you will bounce to coordinate i+aii + a_i (this will keep happening until you bounce past all the trampolines).

You are asked to perform operations of the following form.

  • Type 1: 11 ii xx - Adjust the ithi^{th} trampoline to bounce xx to the right. OR
  • Type 2: 22 ii - Determine the number of bounces before you make it past all the trampolines if you started on the ithi^{th} 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 nn and qq, representing the length of aa and the number of operations respectively. Your next line will contain nn space-separated integers representing the values of aa. Your next qq lines will contain 22 or 33 integers each, representing the operations described. If the line starts with a 11, then you will receive 33 integers, 11, ii, and xx. If the line starts with a 22, then you will receive 22 integers, 22 and ii.

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

  • 1≤n≤1041 \leq n \leq 10^4
  • 1≤q≤1041 \leq q \leq 10^4
  • Queries are 11-indexed.
  • 1≤ai≤1041 \leq a_i \leq 10^4

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 2nd2^{nd} trampoline). The rest of the operations follow...

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.