Getting wrong answer in GCDQ, please help.

I am getting wrong answer in [GCDQ][1]. Can anyone please tell me which inputs it is not satisfying. It is showing me the correct output for all the test cases.
My solution is: https://ideone.com/iTXiM1

There can be one test case also,your program is not working for t=1.

In the subtask, it is given, 2<=T.

@optimus_prime1 Why on earth did you write:
“while(t>=2)”??
t can be 1 too. Just one test case.
Still its wrong I guess.
http://www.codechef.com/viewsolution/5697884. Here have a look at my solution. You can ask any doubts if you want to.

@subhendu_sethi it is given in the constraint t >= 2.

No need to change line when u use scanf.

Please don’t get offended by what I say. I think your submission is quite ugly to read. Also why are you using if conditions to check constraints of test data, Either use assert or don’t check correctness of test data, Codechef puts special testers for this purpose itself.

But that doesn’t having any affect on wrong answer.

@optimus_prime1 Try making the arrays global. Arrays of large sizes (like 10^5 here) cannot always be allocated inside the main function in C/C++.
(Platform dependent stack memory constraint, http://stackoverflow.com/questions/1825964/c-c-maximum-stack-size-of-program)
This solved similar issues for me in the past. See if that helps.

You should not constraint for which constraints is already defined by codechef. Line 24 of your code does not follow the constraints.

No, that line is for putting a flag=1, if my constraint in that line is not following and after that I am using after the next few line that if(flag != 1), means if it is following the constraints.

Few things, you are declaring array inside the main function, Either declare them globally or use allocate memory dynamically. I will recommend you to see the code of setter once and learn about how to code the problem more cleaner and simpler.

Ok, but still getting wrong answer.