CF13E.Holes

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Little Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for one person with following rules:

There are NN holes located in a single row and numbered from left to right with numbers from 1 to NN . Each hole has it's own power (hole number ii has the power aia_{i} ). If you throw a ball into hole ii it will immediately jump to hole i+aii+a_{i} , then it will jump out of it and so on. If there is no hole with such number, the ball will just jump out of the row. On each of the MM moves the player can perform one of two actions:

  • Set the power of the hole aa to value bb .
  • Throw a ball into the hole aa and count the number of jumps of a ball before it jump out of the row and also write down the number of the hole from which it jumped out just before leaving the row.

Petya is not good at math, so, as you have already guessed, you are to perform all computations.

输入格式

The first line contains two integers NN and MM ( 1<=N<=1051<=N<=10^{5} , 1<=M<=1051<=M<=10^{5} ) — the number of holes in a row and the number of moves. The second line contains NN positive integers not exceeding NN — initial values of holes power. The following MM lines describe moves made by Petya. Each of these line can be one of the two types:

  • 00 aa bb
  • 11 aa

Type 00 means that it is required to set the power of hole aa to bb , and type 11 means that it is required to throw a ball into the aa -th hole. Numbers aa and bb are positive integers do not exceeding NN .

输出格式

For each move of the type 11 output two space-separated numbers on a separate line — the number of the last hole the ball visited before leaving the row and the number of jumps it made.

输入输出样例

  • 输入#1

    8 5
    1 1 1 1 1 2 8 2
    1 1
    0 1 3
    1 1
    0 3 4
    1 2
    

    输出#1

    8 7
    8 5
    7 3
    
首页