z-magija
Mr. Little Z has found a job as a magician, and his show is as follows: Mr. Little Z has n cards, and they are all facedown. The audience can demand that Mr. Little Z rotate all the cards starting with some card a up to some card b (a <= b). The can repeatedly demand that different sets of cards be rotated. The audience can then demand that Mr. Little Z tell them whether or not the Kth card is facedown. This game wouldn't be very interesting if Mr. Little Z was looking at the cards, but instead Mr. Little Z is actually doing everything in his head!
Because the audience became much more demanding and wanted faster answers, Mr. Little Z decided to get a mini-computer he can carry with himself when he is answering the audience's questions. Help Mr. Little Z write a program for the mini-computer that can help him quickly answer the audience.
10 7
1 1 10
2 3
1 5 10
2 5
1 1 5
2 5
2 7Output:
1
0
1
0Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.