#B3915. Simplified Hopscotch Game

    ID: 11572 Type: Default 1000ms 256MiB

Simplified Hopscotch Game

Simplified Hopscotch Game

You are given a game consisting of n cells arranged in a row and numbered from 1 to n. Each cell i has a positive integer written on it, denoted by \(a_i\).

The game is played as follows:

  1. The player starts at cell 1.
  2. In each move, if the player is currently on cell \(x\), they jump forward exactly \(a_x\) cells, landing on cell \(x + a_x\).
  3. If the player lands exactly on cell \(n\), the game ends with a victory.
  4. If the player jumps to a cell beyond cell \(n\) (i.e. \(x+a_x > n\)), the player goes out-of-bound and the game ends with a loss.

Your task is to determine:

  1. Whether the player wins (i.e. lands exactly on cell \(n\)). Print 1 if the player wins, otherwise 0.
  2. The total number of jumps performed by the player.
  3. </p>

    inputFormat

    The first line of input contains a single integer n (\(1 \leq n \leq 10^5\)), denoting the number of cells.

    The second line contains n space-separated positive integers \(a_1, a_2, \ldots, a_n\) where each \(a_i\) represents the number written on the i-th cell.

    outputFormat

    Output two integers separated by a space. The first integer is 1 if the player wins (i.e. lands exactly on cell \(n\)), or 0 otherwise. The second integer is the total number of jumps performed.

    sample

    5
    3 1 2 1 1
    1 2