#C5270. Frog Jump Challenge
Frog Jump Challenge
Frog Jump Challenge
The problem is a variation of the well-known Jump Game. Given a row of stones where each stone has a non-negative integer indicating the maximum number of steps that can be jumped from that stone, your task is to determine whether the frog can reach the last stone starting from the first stone.
If the frog can reach the end, output "Possible"; otherwise, output "Impossible".
Mathematically, for a given list \(a_0, a_1, \dots, a_{n-1}\) the frog can travel from stone 0 to stone \(n-1\) if there exists an index sequence \(0 = i_0 < i_1 < \dots < i_k = n-1\) such that \(i_{j+1} - i_{j} \leq a_{i_j}\) for all \(j\). The solution involves determining the maximum reachable index while iterating through the list.
inputFormat
The input is read from standard input (stdin). The first line contains an integer \(T\) denoting the number of test cases. Each test case consists of two lines.
- The first line of each test case contains an integer \(N\) — the number of stones.
- The second line contains \(N\) non-negative integers separated by spaces which represent the maximum jump lengths from each stone.
outputFormat
For each test case, output a single line to standard output (stdout) containing either "Possible" if the frog can reach the last stone, or "Impossible" otherwise.
## sample2
5
2 3 1 1 4
6
3 2 1 0 4 2
Possible
Impossible
</p>