CF1725K.Kingdom of Criticism

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

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 NN buildings. Initially, building ii has a height of AiA_i units.

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

In 11 minute, the kingdom's construction team can increase or decrease the height of any building by 11 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 ll and rr 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 QQ 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 kk to be ww units ( 1kN1 \leq k \leq N , 1w1091 \leq w \leq 10^9 ).
  • 2 k: The kingdom's construction team wants you to find the height of building kk ( 1kN1 \leq k \leq N ).
  • 3 l r: The residents currently do not like buildings with heights between ll and rr units inclusive ( 2lr10912 \leq l \leq r \leq 10^9-1 , rlr-l is odd).

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

输入格式

The first line contains a single integer NN ( 1N41051 \leq N \leq 4 \cdot 10^5 ) — the number buildings in the kingdom.

The second line contains NN integers A1,A2,,ANA_1, A_2, \ldots, A_N ( 1Ai1091 \leq A_i \leq 10^9 ) — the initial heights of the buildings.

The next line contains a single integer QQ ( 1Q41051 \leq Q \leq 4 \cdot 10^5 ) — the number of queries.

The jj -th of the next QQ lines contains the jj -th query as described. There is at least one query of type 22 .

输出格式

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

输入输出样例

  • 输入#1

    5
    2 6 5 6 2
    9
    1 5 10
    2 5
    1 1 3
    3 3 6
    3 8 9
    1 2 9
    2 3
    2 2
    2 4

    输出#1

    10
    7
    9
    7

说明/提示

After the 11 -st query, the height of each building is 2,6,5,6,102, 6, 5, 6, 10 .

After the 33 -rd query, the height of each building is 3,6,5,6,103, 6, 5, 6, 10 .

After the 44 -th query, the height of each building is 2,7,7,7,102, 7, 7, 7, 10 .

After the 55 -th query, the height of each building is 2,7,7,7,102, 7, 7, 7, 10 .

After the 66 -th query, the height of each building is 2,9,7,7,102, 9, 7, 7, 10 .

首页