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

Автор brainstorm, история, 9 лет назад, По-английски

http://codeforces.net/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?

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

»
9 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

I doubt anybody will read your submission with such formatting

»
9 лет назад, # |
  Проголосовать: нравится +38 Проголосовать: не нравится

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.