시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
3 초 | 1024 MB | 68 | 22 | 20 | 36.364% |
Let’s call an array of integers $[b_1, b_2, \dots , b_m]$ good, if we can partition all of its elements into $2$ nonempty groups, such that the bitwise $\texttt{AND}$ of the elements in the first group is equal to the bitwise $\texttt{OR}$ of the elements in the second group. For example, the array $[1, 7, 3, 11]$ is good, as we can partition it into $[1, 3]$ and $[7, 11]$, where $1 \texttt{ OR } 3 = 3$, and $7\texttt{ AND }11 = 3$.
You are given an array $[a_1, a_2, \dots , a_n]$, and have to answer $q$ queries of form: is subarray $[a_l , a_{l+1}, \dots , a_r]$ good?
The first line of the input contains two integer $n$, $q$ ($1 \le n \le 10^5$, $1 \le q \le 10^5$) — the length of the array and the number of the associated queries.
The second line of the input contains $n$ integers $a_1, a_2, \dots , a_n$ ($0 \le a_i \le 2^{30} - 1$) — the elements of the array.
The $i$-th of the next $q$ lines contains $2$ integers $l_i$, $r_i$ ($1 \le l_i \le r_i \le n$) — describing the $i$-th query.
For each query, output YES
, if the correspondent subarray is good, and NO
, if it’s not.
5 15 0 1 1 3 2 1 1 1 2 1 3 1 4 1 5 2 2 2 3 2 4 2 5 3 3 3 4 3 5 4 4 4 5 5 5
NO NO YES YES YES NO YES YES YES NO NO YES NO NO NO