#P4119. [Ynoi2018] 未来日记

    ID: 3053 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2018并查集O2优化块状链表,块状数组,分块Ynoi

[Ynoi2018] 未来日记

Description

Yuno Gasai gave you a sequence aa of length nn, with mm operations.

  1. Replace all occurrences of xx with yy within the interval [l,r][l, r].
  2. Query the kk-th smallest value within the interval [l,r][l, r].

Input Format

The first line contains two integers nn and mm.

The second line contains nn integers representing the sequence aa.

The next mm lines:

1 l r x y: Replace all xx in [l,r][l, r] with yy.

2 l r k: Query the kk-th smallest value in [l,r][l, r].

Output Format

For each query, output one integer as the answer.

3 3
2 3 3
2 1 3 1
1 1 3 3 1
2 1 3 2
2
1

Hint

Idea: f321dd, Solution: f321dd & nzhtl1477, Code: nzhtl1477 & Claris, testdata: nzhtl1477 & Juan_feng.

Constraints: 1n,m,ai1051 \le n, m, a_i \le 10^5.

By f321dd & nzhtl1477 & Claris.

Translated by ChatGPT 5