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

Автор antirsi, 12 лет назад, По-английски

While solving theCodeforces Round #192 (Div. 2), problem: (A) Cakeminator, I noticed that the output differs whenever I use the gcc compiler as opposed to the microsoft one.

The solution was judged correct, but only when I used the microsoft c++ compiler.

Here are the links to the two solutions:

gcc

msc++

Can anyone point out what causes this weird behavior?

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

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

this " if(row[r — 1] != i) row[r++] = i; " and this "if(col[c — 1] != j) col[c++] = j;"

does not look good to me, both "r" and "c" variables are set to zero, and when those lines executed for the first time you will try to access row[-1] and col[-1], which is undefined behaviour