#C6486. Planet Teleportation
Planet Teleportation
Planet Teleportation
In this problem, you are given a sequence of non-negative integers (T_0, T_1, \ldots, T_{n-1}) representing the maximum teleportation jump you can make from each corresponding planet. The planets are numbered from 0 to (n-1), and your task is to determine whether it is possible to reach the last planet (planet (n-1)) starting from the first planet (planet 0).
From a given planet (i), you can jump to any planet (j) such that (i < j \le i+T_i). If you can eventually reach planet (n-1) following these rules, then the journey is considered "Possible"; otherwise, it is "Impossible".
Example:
For (T = [2, 3, 1, 1, 4]), starting from planet 0, you can jump to planet 1 or 2. A valid sequence of jumps is 0 (\to) 1 (\to) 4, so the output is "Possible".
Note: The input and output should be handled via standard input and output streams.
inputFormat
The first line of the input contains a single integer (n) ( (1 \le n \le 10^5) ), representing the number of planets. The second line contains (n) space-separated non-negative integers (T_0, T_1, \ldots, T_{n-1}), where each (T_i) represents the maximum number of steps you can teleport forward from planet (i).
outputFormat
Output a single line containing either "Possible" if it is possible to reach the last planet from the first planet, or "Impossible" otherwise.## sample
1
0
Possible