#SRD0000011. Những chiếc hố (Holes)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Những chiếc hố (Holes)
Holes
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are holes in a row, indexed from to . Hole has a positive power . A ball dropped at hole immediately jumps to . If the destination is still in the row, the same rule is applied again. Once the next position is greater than , the ball leaves the row.
Process operations in input order:
0 a b: Assign the power of hole to , replacing its previous value.1 a: Drop a ball into hole and report the last hole visited before leaving the row and the total number of jumps, including the final jump out of the row.
Since every power is positive, the ball always moves right and eventually exits. Ball-dropping queries do not modify the powers.
Input
The first line contains . The second line contains . Each of the next lines is either 0 a b or 1 a.
Output
For each type-1 operation, print last jumps on a separate line: the final in-row hole and the number of jumps.
Subtasks
- Subtask 1 (15 points): ; ; ; trong lệnh
0 a b, ; trong lệnh1 a, . - Subtask 2 (20 points): ; ; ; trong lệnh
0 a b, ; trong lệnh1 a, . - Subtask 3 (25 points): ; ; ; trong lệnh
0 a b, ; trong lệnh1 a, . - Subtask 4 (40 points): ; ; ; trong lệnh
0 a b, ; trong lệnh1 a, .
Examples
Input
8 5
1 1 1 1 1 2 8 2
1 1
0 1 3
1 1
0 3 4
1 2
Output
8 7
8 5
7 3
Explanation
Initially the visited holes from are , followed by the exit: last hole , jumps. After 0 1 3, the path is : jumps. After 0 3 4, starting at visits and exits after jumps.