After pocketing a lot of money selling pancakes, Marcelo decided to shake things up and…
- User
After pocketing a lot of money selling pancakes, Marcelo decided to shake things up and get some exercise to build his dream summer. Since he didn't have many facilities, he started by walking on the sidewalk in front of his house.
The sidewalk in front of Marcello's house is in the form of a strip with n n is the house, each house is black or white. He, who is calm and restless, goes from his current house to the neighboring house every minute, provided that the color of that house is different from his current house.
He is very excited for this task and asks you for each of the q q The state he has in his mind, tell if he can start from his desired origin house and finish in his desired destination house by meeting the above conditions.
input In the first line of the input n n and q q is shown to indicate the number of houses and the number of states in Marcello's mind, respectively. 2 ≤ n ≤ 100
000 2≤n≤100 000 1 ≤ q ≤ 100
000 1≤q≤100 000 In the second input line n n is the number that comes if the number i Let the i-th be equal to zero i I am white and otherwise black. on the line i iam from q q The next line is two numbers s i s i and e i e i It is stated that Marcello's desired starting and ending house. 1 ≤ s i , e i ≤ n 1≤s i ,e i ≤n s i ≠ e i s i
=e i
output output q q has a line. If Marcello could walk from home s i s i Start at home e i e i Finish on the line i First, print YES and otherwise NO.
Example Sample entry 1 5 3 0 1 0 0 1 1 3 2 4 4 5 Plain text Sample output 1 YES No YES
- Assistant
To solve this problem, we need to check if Marcelo can walk from the starting house (s_i) to the destination house (e_i) following the rule: he can only move to a neighboring house if it is a different color than his current house.