P17673 [IO 2025 #4] Thermal Ropes
Description
The "Horsemen" team is preparing the last trick of their show: they will break into a heavily protected data center in sync with the live broadcast.
To crack the system, they must press the activation button exactly $T$ seconds after the show starts. However, all clocks, timers, and electronic devices in the building are blocked by the security system. The team only has four special thermal ropes, which can be lit from one end or from both ends.
At any moment, the Horsemen can perform the following operations:
- Take a rope that is not burning and light it from one end or from both ends.
- Take a rope that is burning from only one end, and either light its other end or put it out.
- Take a rope that is burning from both ends, and either put out one end or put out both ends.
Multiple operations on different ropes can be performed at the same moment.
The Horsemen know that the $i$-th rope, if lit from one end, burns out in exactly $t_i$ seconds; if a rope has been burning from one end for $x$ seconds and then the other end is lit, it needs $\frac{t_i-x}{2}$ more seconds to burn out. The ropes do not burn at a uniform rate, so the length of a rope cannot tell how much time has passed since it was lit.
Assuming the show starts at the moment they light or put out some rope, determine whether it is possible to measure exactly $T$ seconds.
Input Format
The first line contains the number of test cases $t$, with $1\le t\le 10^4$.
Each test case consists of five integers $t_1,t_2,t_3,t_4,T$, with $1\le t_1,t_2,t_3,t_4\le 10^8$ and $1\le T\le 4\cdot 10^8$.
Output Format
For each test case, output `YES` or `NO` according to the answer. The case of the letters does not matter.
Explanation/Hint
Translated by QwenWork