Блог пользователя Midsid

Автор Midsid, история, 8 часов назад, По-английски

For test case x = 0 and y = 0 the answer should be 0 and when I run it on my compiler the output is 0 but when I submitted the code, the checker showed 2 as output. https://codeforces.me/contest/2075/submission/311384533

edit : There was undefined behavior in this code because I passed 0 to __builtinclz .Thanks for helping.

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
8 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Bro, I think it's an out-of-bounds error. In your compiler, the code might be assigning a default value of 0 to the out-of-bounds index, but on Codeforces, it's probably picking up a garbage value

»
7 часов назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

It seems that your code has UB (Undefined Behavior). You can add -fsanitize=undefined to your compile command to detect UB. However, adding this to your compile command may make your program run slower.

»
6 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by Midsid (previous revision, new revision, compare).