Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

brainstorm's blog

By brainstorm, history, 9 years ago, In English

http://mirror.codeforces.com/contest/449/submission/14705739

on my system the output for the given test case is coming to be "2" , while codeforces compiler is giving "1" .
why so?

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it +3 Vote: I do not like it

I doubt anybody will read your submission with such formatting

»
9 years ago, # |
  Vote: I like it +38 Vote: I do not like it

No need to read the code when tools can detect the problem.

Compiling with -fsanitize=undefined shows error

a.cpp:51:16: runtime error: load of value 190, which is not a valid value for type 'bool'

it means memory corruption, uninitialized memory or out of bound access.

Compiling with -D_GLIBCXX_DEBUG shows

/usr/include/c++/5.1.1/debug/vector:406:error: attempt to subscript container with out-of-bounds index 5, but container only holds 5 elements.

most likely this is case 3. out of bound access. Replacing [] with at confirms it.