P27900 [洛谷] [Language Monthly Contest 202401] Hopscotch
普及-
题目描述

Problem Background

Hopscotch, also known as "jump plane," is a global children's game and one of the traditional sports games in Chinese folk culture. It is highly趣味性 and entertaining, and was once extremely popular among children.

Problem Description

We now present a simplified version of the hopscotch game:

$n$ squares are arranged in a line from left to right, numbered as $1, 2, \cdots, n$. Each square has a positive integer, where the $i$-th square has the integer $a_i$.

The rules of the game are as follows: Initially, the player stands on the $1$-st square and needs to make several jumps. Each jump requires the player to move forward by the number of squares indicated by the integer on the current square. Formally, if the player is on the $x$-th square, they need to jump to the $(x + a_x)$-th square.

If the player jumps beyond the $n$-th square, it is considered "out of bounds"; if the player lands exactly on the $n$-th square, it is considered a "win." In both cases, the player must stop jumping.

Given the number of squares and the integers on them, you need to determine:

  1. Whether the player wins after stopping jumping, i.e., whether the player can land exactly on the $n$-th square.
  2. The total number of jumps made by the player after stopping jumping.

Input Format

The input consists of two lines.

The first line contains an integer $n$, representing the number of squares.
The second line contains $n$ integers $a_1, a_2, \cdots, a_n$, representing the numbers on each square.

Output Format

The output consists of two lines.

The first line is a string. If the player lands exactly on the $n$-th square after stopping jumping, output Yes; otherwise, output No.
The second line contains an integer, representing the total number of jumps made by the player.

Sample Input and Output

Sample Input #1

6
1 1 3 7 8 5

Sample Output #1

Yes
3

Sample Input #2

4
2 7 3 5

Sample Output #2

No
2

Notes

Sample 1 Explanation

Image

Sample 2 Explanation

Image

Data Range and Constraints

For $100\%$ of the data, it is guaranteed that $1 \leq n \leq 10^6$ and $1 \leq a_i \leq 10^4$.

Test Case Number $n$ Special Properties
$1$ $= 1$ None
$2 \sim 4$ $\leq 100$ None
$5$ $\leq 10^6$ $a_i = 1$
$6, 7$ $\leq 10^6$ $a_i = 2$
$8 \sim 10$ $\leq 10^6$ None
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
6 1 1 3 7 8 5
样例输出
Yes 3