WA in MARBLEGF

I am having a problem in solving this question - CodeChef: Practical coding for everyone
here is my solution-CodeChef: Practical coding for everyone
If someone could help me to point out the error…Thank you…

I was facing some similar problem, though your solution has got some different approach in taking the inputs, It doesn’t work for same problem. The issue might be that there is an extra ‘\n’ between the test cases or a space before ‘\n’ that is used to move to next test case, for which the code gives wrong answer(Bcoz it starts taking wrong inputs from then on).

http://discuss.codechef.com/questions/33029/cin-works-but-getchar-doesnt-while-taking-a-char-input

In your code I don’t know why did you use the temp which never you never used after scanning to get the answer. but you can change that to get the answer.

I ran your solution and you could avoid using temp. and change the scanf() statement in the while(q--) loop to

scanf("\n%c %lld %lld",&ch,&start,&end);