XOR on Segment - interesting trick

c-plus-plus
codeforces
compiler
optimization

#1

For this question on codeforces, where the intended solution is using segment tree, I found some naive solution which are getting accepted.

  1. sol-1
  2. sol-2

Can someone explain me how these codes are passing all the test cases and what is the optimisation used here?

MY Reference


#2

The solutions are passing because the timelimit/tesetcases are not strict enough. The only trick in these brute force solutions is to use integers inistead of long long for accumulating (possibly a time win of 50%). Only when the integer might overflow a long long is used to store the complete sum.


#3

so, processing on integer data type is faster than Long Long data type, and we are processing on long long data type only when it is needed?