H Traveling on the Axis
BaoBao is taking a walk in the interval [0,n] on the number axis, but he is not free to move, as at every point (i−0.5) for all i∈[1,n], where i is an integer, stands a traffic light of type ti (ti∈{0,1}).
BaoBao decides to begin his walk from point p and end his walk at point q (both p and q are integers, and p<q). During each unit of time, the following events will happen in order:
- Let's say BaoBao is currently at point x, he will then check the traffic light at point (x+0.5). If the traffic light is green, BaoBao will move to point (x+1); If the traffic light is red, BaoBao will remain at point x.
- All the traffic lights change their colors. If a traffic light is currently red, it will change to green; If a traffic light is currently green, it will change to red.
A traffic light of type 0 is initially red, and a traffic light of type 1 is initially green.
Denote