P7721 [Ynoi2007] rvrewsus
Description
Given an array $a_1,a_2,\dots,a_n$ and a positive integer $b$, please answer $q$ queries of the form $[l,r,L,R]$.
The symbol $\land$ denotes logical AND.
In each query, you need to:
1. Create a **set with no duplicates** $S=\{a_i:l\le i\le r\land L\le a_i\le R\}$.
2. Define the function $r(k)=\begin{cases}\min (x:x\in S)&k=0\\\min(x:x\in S\land r(k-1)
Input Format
The first line contains three integers $n,b,q$.
The next line contains $n$ integers $a_1,a_2,\dots,a_N$.
The next $q$ lines each contain four positive integers $l,r,L,R$, representing one query.
Output Format
Output $q$ lines, each being the answer to the corresponding query.
Explanation/Hint
Idea: nzhtl1477, Solution: ccz181078, Code: w33z, Data: w33z.
- Subtask 1 (2 pts): $n,q\le5000$.
- Subtask 2 (3 pts): $n,q\le5\times10^4$.
- Subtask 3 (3 pts): $R-L\le 300$.
- Subtask 4 (7 pts): $b=1$.
- Subtask 5 (7 pts): all $a_i$ are pairwise distinct.
- Subtask 6 (11 pts): $L=0,R=333333333333333396$.
- Subtask 7 (67 pts): no additional constraints.
For all testdata, $1\le n,q\le2\times10^5$, $1\le L\le R\le n$, $0\le b,a_i,L,R