hiho week 310 register

Ended

Participants:33

Verdict:Accepted
Score:100 / 100
Submitted:2020-06-07 11:12:34

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cstdio>
#include <iostream>
using namespace std;
const int MAXN = 100000 + 10;
int n, q, A[MAXN], ans[MAXN];
int main(){
    int op, x, y;
    scanf("%d", &n);
    for(int i=1; i<=n; ++i){
        scanf("%d", &A[i]);
    }
    for(int i=1; i<=6; ++i){
        ans[i] = -1;
    }
    scanf("%d", &q);
    for(int i=0; i<q; ++i){
        scanf("%d", &op);
        if(op == 1){
            scanf("%d", &x);
            if(ans[x] == -1){
                int st = x;
                ans[x] = 0;
                while(st <= n){
                    ans[x]++;
                    st += A[st];
                }
            }
            printf("%d\n", ans[x] );
        }else{
            scanf("%d %d", &x, &y);
            A[x] = y;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX