[Solution] Kingdom of Criticism Codeforces Solution
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 buildings. Initially, building has a height of units.
At any point in time, the residents can give a new criticism, namely they currently do not like buildings with heights between and units inclusive for some two integers and . It is known that is always odd.
In minute, the kingdom's construction team can increase or decrease the height of any building by 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 and 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.
There will be 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 to be units (, ).
- 2 k: The kingdom's construction team wants you to find the height of building ().
- 3 l r: The residents currently do not like buildings with heights between and units inclusive (, is odd).
Note that each change in height still persists to the next queries.
The first line contains a single integer () — the number buildings in the kingdom.
The second line contains integers () — the initial heights of the buildings.
The next line contains a single integer () — the number of queries.
The -th of the next lines contains the -th query as described. There is at least one query of type .
For each query of type , output a line containing an integer representing the height of the building asked.
No comments:
Post a Comment