P11245 Lingering Snow

Background

[English statement](https://www.luogu.com.cn/problem/U500139). **You must submit your code at the Chinese version of the statement.** If I were to walk with you on the same road again, I would also tell you the distant stars an endless number of words, and then tell you once more. You smiled and placed your raised finger at the corner of your mouth, as if hinting to me that you were actually the distant Polestar. The sad thing is that in this world, there is no longer the Little Prince, nor the pilot from this day last year. How much idle sorrow is there? A river of misty grass, a city full of drifting catkins, and plum-rain in the season when plums turn yellow. ![](https://pic.imgdb.cn/item/670fd597d29ded1a8c604148.png)

Description

Given a set $S$. We define a binary string $t$ (a $\tt 01$ string) to be bad if and only if there exists $k \in S$ such that $t$ contains a substring $t'$ of length $2k$, and $t'$ contains exactly $k$ $\tt 0$'s and $k$ $\tt 1$'s. Conversely, a $\tt 01$ string that is not bad is good. Little Y has $q$ queries. Each query gives $L, R, m, n$, meaning $S = \{x \in \N_+ \mid L \leq x \leq R\}$. Determine whether there exists a good string $t$ such that $t$ contains exactly $m$ $\tt 0$'s and $n$ $\tt 1$'s.

Input Format

The first line contains an integer $q$, the number of queries. For each query: - A single line with four integers $L, R, m, n$.

Output Format

Output $q$ lines in total. For each query, output one string, `Yes` or `No`, to indicate your answer. You should output `Yes` if and only if your answer to Little Y's question is affirmative. In this problem, the output is case-insensitive. That is, `yEs`, `yes`, `Yes`, `YES`, etc. are all considered `Yes`; similarly for `No`.

Explanation/Hint

### Sample Explanation - For the first test case, since it contains $\tt 0, 1$ but $L = 1$, it must be invalid. - For the second test case, there exists $t = \tt 0011111100$. It is easy to prove that this is valid. - For the third test case, this is indeed the case. - For the other test cases, I cannot give you a clear answer for now. ### Constraints **This problem uses bundled tests and subtask dependencies.** - Subtask 0 (0 pts): Samples. - Subtask 1 (13 pts): $q \leq 10^3$, $n + m \leq 14$, $R \leq 14$. - Subtask 2 (20 pts): $\sum \max(n, m, L, R) \leq 5\times 10^3 + 5$. Depends on subtasks $0$. - Subtask 3 (13 pts): $\sum \max(n, m, L, R) \leq 10^7 + 100$. Depends on subtasks $0 \sim 2$. - Subtask 4 (13 pts): $L = R$. - Subtask 5 (41 pts): No special constraints. Depends on subtasks $0 \sim 4$. For all testdata, it is guaranteed that $1 \leq q \leq 10^5$, $1 \leq L \leq R \leq 10^{18}$, $0 \leq n, m \leq 10^{18}$, $n + m \geq 1$. Translated by ChatGPT 5