P3901 Distinctness in a Sequence

Description

Given a sequence $A_1, A_2, \ldots, A_N$ and $Q$ queries $(L_i, R_i)$, determine whether $A_{L_i}, A_{L_i+1}, \ldots, A_{R_i}$ are all different from each other.

Input Format

The first line contains two integers $N, Q$. The second line contains $N$ integers $A_1, A_2, \ldots, A_N$. Then $Q$ lines follow, each containing two integers $L_i, R_i$.

Output Format

For each query, output one line: `Yes` or `No`.

Explanation/Hint

For $50\%$ of the testdata, $N, Q \le 10^3$. For $100\%$ of the testdata, $1 \le N, Q \le 10^5$, $1 \le A_i \le N$, $1 \le L_i \le R_i \le N$. Translated by ChatGPT 5