33OJ
登录 注册

#P13981. 数列分块入门 6

数列分块入门 6

Background

The constraints of the testdata in Luogu's "Introduction to Sequence Block Decomposition" series differ from those of the original problems.

Problem Description

You are given a sequence of length nn and nn operations. The operations involve single-point insertion and single-point queries. The testdata are generated randomly; see the constraints for the generation method.

Input Format

The first line contains one integer nn.

The second line contains nn integers, where the ii-th integer is aia_i, separated by spaces.

Then nn lines follow, each describing one operation. Each line first contains one integer opt\mathrm{opt}, separated by a space.

If opt=0\mathrm{opt} = 0, then two more integers l,rl, r follow on the same line, meaning that the integer rr is inserted right before the ll-th integer.

If opt=1\mathrm{opt} = 1, then one more integer cc follows on the same line, meaning that you should query the value of aca_c.

Output Format

For each query, output one integer on a single line giving the answer.

4
1 2 2 3
0 1 3
1 4
0 1 2
1 2
2
3

Hint

Subtasks

Subtask 1 (40 points): 1≤n≤1000001 \leq n \leq 100000, −231≤ai,r≤231−1-2^{31} \leq a_i, r \leq 2^{31}-1.

Subtask 2 (60 points): 1≤n≤3000001 \leq n \leq 300000, −231≤ai,r≤231−1-2^{31} \leq a_i, r \leq 2^{31}-1.

For all testdata, 1≤n≤3000001 \leq n \leq 300000 and −231≤ai,r≤231−1-2^{31} \leq a_i, r \leq 2^{31}-1. opt∈{0,1}\mathrm{opt} \in \{0,1\}, and 1≤l,c≤1 \leq l, c \leq the number of integers currently present in the sequence when the operation is performed.

The testdata guarantee that, for each operation, opt\mathrm{opt} is first generated uniformly at random as 00 or 11 with equal probability, and the remaining operation parameters are then drawn uniformly at random from all valid possibilities.

Translated by QwenWork