MATCHS-TLE for all test cases except first test case



Please help me to identify that where is my code going wrong…


i have just some parts of your code ( only 2 lines) and got a AC
link :
added these two lines:
1.for fast IO
2. you used q as long long int array of a large size i used vector instead of array so that i can save space.


Why I am getting TLE if I can’t use vector in place of array?


its interesting , there is no problem with using an array the problem lies using the following statement
int q[100000]={ }; or int q[100000]={0};
replace the statement with int q[100000];
you will get an AC.
I think that the array is set to a given value so it consumes time and results in a TLE , though I am not sure about this.


Sorry, i was wrong. I tried to change your code. Moving the initialization of the variables and some conditions, and I got AC.


Ok, I found the cause of the problem with some tests.
The real problem is the inizialization of long long int q[100000] = {}; only by moving this line of code out of the while loop, we get AC.


Thanks, @andrew1234, @baby_stark
I got it…