luogu#P4119. [Ynoi2018] 未来日记

[Ynoi2018] 未来日记

Background

So, Xiaoxue’s (pinyin) future belongs to Yuno’s~

Hmm... I know what your future will be like.

Listen up, I am Yuno Gasai.

Because Xiaoxue changed the future, the three of them could be together...

Why...

That makes me the bad guy...

I won’t stab.

Because... this is the future.

This... is my home.

Problem 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