#P6688. 可重集

    ID: 5644 远端评测题 2000ms 500MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2020线段树树状数组洛谷原创O2优化哈希,HASH洛谷月赛

可重集

Description

You are given a non-negative integer sequence a1,a2,a3,,ana_1,a_2,a_3,\ldots, a_n of length nn, and qq operations. Each operation first gives a parameter opop:

  • If op=0op=0, then two parameters x,yx,y are given, and you need to modify axa_x to yy.

  • If op=1op=1, then four parameters l1,r1,l2,r2l_1,r_1,l_2,r_2 are given (it is guaranteed that r1l1=r2l2r_1-l_1=r_2-l_2). You need to determine whether the interval [l1,r1][l_1,r_1] and the interval [l2,r2][l_2,r_2] are essentially the same. If they are, output YES, otherwise output NO.

Definition of being essentially the same: let the interval length be len\text{len}. Let the sequence p1plenp_{1}\dots p_{\text{len}} be the result of sorting al1ar1a_{l_1}\dots a_{r_1} in non-decreasing order, and let the sequence q1qlenq_{1}\dots q_\text{len} be the result of sorting al2ar2a_{l_2}\dots a_{r_2} in non-decreasing order. There exists an integer kk such that i,pi+k=qi\forall i,p_i+k=q_i.

Input Format

The first line contains two positive integers n,qn,q, representing the length of the sequence and the number of operations.

The second line contains nn non-negative integers, representing a1,a2,a3,,ana_{1},a_2,a_3,\ldots,a_n.

The next qq lines each describe one of the operations above.

Output Format

For each operation with op=1op=1, output whether the two intervals are essentially the same. If yes, output YES, otherwise output NO.

12 6
1 1 4 5 1 4 2 2 5 2 3 3
1 1 3 7 9
1 2 3 5 6
1 1 3 2 4
0 7 1
1 1 4 2 5
1 5 7 8 10
YES
YES
NO
YES
YES

Hint

  • Subtask 1 (2525 pts): 1n,q10001\leq n,q \leq 1000.

  • Subtask 2 (2525 pts): 1n,q1051\leq n,q \leq 10^5, 0ai,y1000\leq a_i,y\leq 100.

  • Subtask 3 (2525 pts): 1n,q1051\leq n,q \leq 10^5.

  • Subtask 4 (2525 pts): no special constraints.

You can only get the score of a subtask if you pass all testdata in that subtask.

For all data: 1n,q1061\leq n,q \leq 10^6, 1xn1\leq x \leq n, 0ai,y1060\leq a_i,y \leq 10^6. Also, for all l,rl,r, 1lrn1\leq l\leq r\leq n.

Translated by ChatGPT 5