RRCODE - Editorial

@stefanpochmann yes, that’s the culprit. Thanks

@devanshug i know its written in the problem statement but many people have got WA because is this(including me) , sorry i didn’t see it was for TLE in code not wa in this case. .

Try s = raw_input().strip(), that’s what my solution needed. If that doesn’t help, also try split() instead of split(’ '), don’t know why you’re doing that anyway.

1 Like

changed. thanks :slight_smile:

s = raw_input().strip() worked…whats the use of strip()??

@r3gz3n it removes any whitespace from the end or beginning of the string,
in this case the input

But the question says " It is guaranteed that there will be no whitespaces before or after Operator."??

@sobhagya - thanks for input… but could not get your point. if I am continuing to next test case when k==0 by simply printing the given ‘ans’ and not reading the array/operator, then why should it at all give ‘Time Limit Exceed’ problem. in fact for k==0, this reduces the task of reading the array unnecessarily… would you mind explaining a bit ?

@sayantancs Try this input:

2
5 0 1
1000000000 2 3 4 5
XOR
2 2 2
3 3
AND

If you do not care to read off the array in the first test case, then you take the value of n for the second test case as 10^9, k as 2 and ans as 3, and proceed with a loop that runs 10^9 times to read the array that actually does not exist.

I think, now, what @sobhagya tried to say has become clear.

The point is, you need to simply read the array off, to get to the next input. (This is necessary!!)

3 Likes

I too got frustrated for not handling k==0 case.
I got 2 WA for that.

@tijoforyou - okk. got it… thanks… largely overlooked that fact :frowning:

gets is deprecated. You shave have taken input by

 
scanf("%s", str);