Requests
You have an array a
of length n
. You will receive q
queries of two types:
Update the
p
-th element in the arraya
tov
.Retrieve the
p
-th element from the arraya
.
Interaction
You need to implement the following three functions:
void init(integer n, array of integers a)
n
— the length of the array.a
— the array of integers.This function is called first and only once. It provides the size of the array and the array itself. The other two functions will be called only after this function has been executed.
void upd(integer p, integer v)
p
— the position in the array.v
— the new value to be assigned.This function is called to execute a query of the first type.
integer ask(integer p)
p
— the position in the array.This function is called to execute a query of the second type.
The function should return an integer, which is the result of the query.
Input Format
The first line contains two integers n and m (1 ⩽ n ⩽ 100, 1 ⩽ m ⩽ 1,000) — the length of the array and the number of queries.
The second line contains n integers a[1]
, a[2]
, ..., a[n]
(1 ⩽ a[i]
⩽ 100) — the elements of the array. Each of the next m
lines describes a query and follows one of these formats:
"1 p v" (1 ⩽ p ⩽ n, 1 ⩽ v ⩽ 100) — specifies the position and the new value.
"2 p" (1 ⩽ p ⩽ n) — specifies the position.
Output Format
For each query of the second type, output one integer — the result of the query.
Blocks:
(20 points) n ⩽ 10; m ⩽ 100;
a[i]
,v[i]
⩽ 20;(20 points) n ⩽ 30; m ⩽ 300;
a[i]
,v[i]
⩽ 30;(20 points) n ⩽ 50; m ⩽ 500;
a[i]
,v[i]
⩽ 50;(20 points) n ⩽ 75; m ⩽ 750;
a[i]
,v[i]
⩽ 75;(20 points) without additional constraints.