#P11245. 残雪

    ID: 12185 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>贪心洛谷原创Special JudgeO2优化构造洛谷月赛

残雪

Background

English statement. 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.

Problem Description

Given a set SS. We define a binary string tt (a 01\tt 01 string) to be bad if and only if there exists kSk \in S such that tt contains a substring tt' of length 2k2k, and tt' contains exactly kk 0\tt 0's and kk 1\tt 1's. Conversely, a 01\tt 01 string that is not bad is good.

Little Y has qq queries. Each query gives L,R,m,nL, R, m, n, meaning S={xN+LxR}S = \{x \in \N_+ \mid L \leq x \leq R\}. Determine whether there exists a good string tt such that tt contains exactly mm 0\tt 0's and nn 1\tt 1's.

Input Format

The first line contains an integer qq, the number of queries. For each query:

  • A single line with four integers L,R,m,nL, R, m, n.

Output Format

Output qq 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.

5
1 2 3 5
3 3 4 6
5 6 11 13
10 15 33 22
10 13 11 11
No
Yes
No
Yes
No

Hint

Sample Explanation

  • For the first test case, since it contains 0,1\tt 0, 1 but L=1L = 1, it must be invalid.
  • For the second test case, there exists t=0011111100t = \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): q103q \leq 10^3, n+m14n + m \leq 14, R14R \leq 14.
  • Subtask 2 (20 pts): max(n,m,L,R)5×103+5\sum \max(n, m, L, R) \leq 5\times 10^3 + 5. Depends on subtasks 00.
  • Subtask 3 (13 pts): max(n,m,L,R)107+100\sum \max(n, m, L, R) \leq 10^7 + 100. Depends on subtasks 020 \sim 2.
  • Subtask 4 (13 pts): L=RL = R.
  • Subtask 5 (41 pts): No special constraints. Depends on subtasks 040 \sim 4.

For all testdata, it is guaranteed that 1q1051 \leq q \leq 10^5, 1LR10181 \leq L \leq R \leq 10^{18}, 0n,m10180 \leq n, m \leq 10^{18}, n+m1n + m \geq 1.

Translated by ChatGPT 5