Codeforces Round 979 (Div. 2) |
---|
Finished |
Suppose you have an array $$$b$$$. Initially, you also have a set $$$S$$$ that contains all distinct elements of $$$b$$$. The array $$$b$$$ is called orangutan-approved if it can be emptied by repeatedly performing the following operation:
You are given an array $$$a$$$ of length $$$n$$$ and $$$q$$$ queries.
Each query consists of two indices $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le n$$$), and you need to determine whether or not the subarray $$$a_{l}, a_{l+1}, \ldots, a_r$$$ is orangutan-approved.
The first line contains $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
The first line of each test case contains integers $$$n$$$ and $$$q$$$ ($$$1 \leq n,q \leq 2 \cdot 10^5$$$) — the size of $$$a$$$ and the number of queries, respectively.
The following line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$) — the elements of the array $$$a$$$.
The following $$$q$$$ lines contain two integers $$$l$$$ and $$$r$$$ — the endpoints of the subarray for each query ($$$1 \leq l \leq r \leq n$$$).
It is guaranteed that the sum of $$$n$$$ and $$$q$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each query, output "YES" (without quotes) if the subarray from $$$l$$$ to $$$r$$$ is orangutan-approved, and "NO" (without quotes) otherwise.
You can output "YES" and "NO" in any case (for example, strings "yES", "yes" and "Yes" will be recognized as a positive response).
34 21 2 2 11 41 35 31 2 1 2 12 53 51 38 41 2 3 2 1 3 2 31 52 83 56 8
YES YES NO YES YES YES NO YES YES
In the first query of the first testcase, the answer is YES.
In the first query of the second testcase, the answer is NO, because it can be shown that the subarray $$$[2,1,2,1]$$$ cannot become empty through any sequence of valid operations.
Name |
---|