## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Kingdom of Criticism Codeforces Solution

K. Kingdom of Criticism
time limit per test
3 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Pak Chanek is visiting a kingdom that earned a nickname "Kingdom of Criticism" because of how often its residents criticise each aspect of the kingdom. One aspect that is often criticised is the heights of the buildings. The kingdom has $N$ buildings. Initially, building $i$ has a height of ${A}_{i}$ units.

At any point in time, the residents can give a new criticism, namely they currently do not like buildings with heights between $l$ and $r$ units inclusive for some two integers $l$ and $r$. It is known that $r-l$ is always odd.

In $1$ minute, the kingdom's construction team can increase or decrease the height of any building by $1$ unit as long as the height still becomes a positive number. Each time they receive the current criticism from the residents, the kingdom's construction team makes it so that there are no buildings with heights between $l$ and $r$ units inclusive in the minimum time possible. It can be obtained that there is only one way to do this.

Note that the construction team only cares about the current criticism from the residents. All previous criticisms are forgotten.

Solution Click Below:-  👉
👇👇👇👇👇

There will be $Q$ queries that you must solve. Each query is one of the three following possibilities:

• 1 k w: The kingdom's construction team changes the height of building $k$ to be $w$ units ($1\le k\le N$$1\le w\le {10}^{9}$).
• 2 k: The kingdom's construction team wants you to find the height of building $k$ ($1\le k\le N$).
• 3 l r: The residents currently do not like buildings with heights between $l$ and $r$ units inclusive ($2\le l\le r\le {10}^{9}-1$$r-l$ is odd).

Note that each change in height still persists to the next queries.

Input

The first line contains a single integer $N$ ($1\le N\le 4\cdot {10}^{5}$) — the number buildings in the kingdom.

The second line contains $N$ integers ${A}_{1},{A}_{2},\dots ,{A}_{N}$ ($1\le {A}_{i}\le {10}^{9}$) — the initial heights of the buildings.

The next line contains a single integer $Q$ ($1\le Q\le 4\cdot {10}^{5}$) — the number of queries.

The $j$-th of the next $Q$ lines contains the $j$-th query as described. There is at least one query of type $2$.

Output

For each query of type $2$, output a line containing an integer representing the height of the building asked.