eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Worst Locations

Worst Locations

Two pandas \textbf{A} and \textbf{B} like each other. They have been placed in a bamboo jungle (which can be seen as a perfect binary tree graph of \textbf{2^N-1} vertices and \textbf{2^N-2} edges whose leaves are all of the same depth) at different locations. The jungle organizers (yes, such organizers exist), being a bit disorganized, only note down two integers \textbf{X} and \textbf{Y} as an indicator of the location of a panda which is translated as: that panda is now at a vertex whose distance is exactly \textbf{Y} vertices away from the leaf \textbf{X}. The leaves are numbered from \textbf{1} to \textbf{2^\{N-1\}} from left to right. As you might have noticed, this indicator may correspond to more than one vertex. For example, the image below shows possible locations for \textbf{N = 4}, \textbf{X = 3}, \textbf{Y = 3}. \includegraphics{https://static.e-olymp.com/content/4d/4dffd28fdb3cd8aef286477719299cf21f0dfa25.jpg} Back to our two pandas, the indicators of the locations of these two pandas are (\textbf{X_A}, \textbf{Y_A}) and (\textbf{X_B}, \textbf{Y_B}). One can shout to another such that if they are at most \textbf{Z} vertices away from each other, the other can hear that shout. The question is, given the height of the jungle layout, the location indicators of these two pandas and the strength of their shouts, is it possible that these two pandas cannot hear each other's shout? \InputFile The first line of input contains an integer \textbf{T} (\textbf{T} ≤ \textbf{50, 000}) denoting the number of testcases. Each testcase is represented by a single line containing \textbf{6} space-separated integers \textbf{N}, \textbf{X_A}, \textbf{Y_A}, \textbf{X_B}, \textbf{Y_B}, and \textbf{Z} (\textbf{1 }≤ \textbf{N} ≤ \textbf{31}; \textbf{1} ≤ \textbf{X_A}, \textbf{X_B} ≤ \textbf{2^\{N-1\}}; \textbf{0} ≤ \textbf{Y_A}, \textbf{Y_B}, \textbf{Z} ≤ \textbf{2·N - 2}) denoting the height of the perfect binary tree jungle layout, the location indicators of the two pandas, and the strength of their shouts. \OutputFile For each testcase, write "\textbf{YES}" to a single line of output if it is the case that these two pandas might not be able to hear each other's shout, and "\textbf{NO}" otherwise.
Ліміт часу 3 секунди
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
2
4 3 3 3 3 2
4 3 3 3 3 1
Вихідні дані #1
NO
YES
Джерело ACM-ICPC 2010 Jakarta