Why Does XOR Make a Difference in Performance?
Difference between ru1 and en1, changed 645 character(s)
Recently, I faced with one issue where two seemingly similar solutions performed differently.  I want to know why it is happening?↵

[Code 1](http://codeforces.me/contest/2057/submission/300094846): Used an XOR operation (num ^ some_randint) to preprocess numbers before counting their frequencies ↵

[Code 2](https://codeforces.me/contest/2057/submission/300094222): Counted numbers directly without any transformation.↵

Both codec followed identical logic after this step, but code 1 passed the test cases efficiently, while code 2 gotaTLE.↵

WHY? I would be happy if someone could explain.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English elnazar 2025-01-08 00:22:45 645 Initial revision for English translation
ru1 Russian elnazar 2025-01-08 00:22:10 645 Первая редакция (опубликовано)