Quote:
but I don't understand why am I getting a TLE ? I think there is something additional about online judges or STL that I should have known...
The reason is simple: With CodeChef challenges, a strait forward answer is never the right answer, even if results are correct.
You can consider systematically that a very careful analyze of the problem will uncover a mathematical property or transform that lead to huge simplifications and speed up. Even a reasonably fast (general purpose) algorithm will be out performed by the mathematical property.
Said otherwise, it is a challenge because there is a clever handling.
I didn't studied this challenge, but usage of
Xor smells like this kind of things.