Getting WA on a cake-walk simple problem. Please help!!

I read the Editorial. It’s basically the same thing. Still getting WA. I’m very confident that the code is correct :frowning: Please please review. My life is at a standstill :frowning:

Problem:

My submission:
http://www.codechef.com/viewsolution/3105197

temp1 = temp2 doesnt justify that chef guessed it is true.

consider

abcd efgh

here temp1 = temp2 but chef ans should be false;

You can check out my submission

http://www.codechef.com/viewsolution/3106021

its in C but C and C++ are pretty similar

Thanks a lot!