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

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

TASK when I use dynamic memory program1 my submission 4209868 gets wrong answer on test 2. But on my computer it prints 00000007 00000016 00000017 00000025 But when I use vector program2 it passed the second test 4209865 I don't know why. NOTE: I decreased the size from 10000 to 1000 as vector gets Time limit. Here is the submission without changing the size 4209841

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

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

I'd advise you to install exactly the same version of MinGW (4.7.2) as it's used on Codeforces (of course, if you use Windows), and compile with the same keys as on Codeforces. Seems that rigorous testing will help you.

And since your code is not very small, very little people will read it in order to find your bugs.

  • »
    »
    11 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

    The problem appeared because of using Linux. On Linux it prints correct. On Windows it prints incorrect. Thank you.Now I can find MY bugs :) I wonder can't I use dynamic matrix with different column sizes(on Windows)? EDIT The bug:It needs ' memset(myarray, 0, sizeof(myarray)); '

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

there is undefined behavior in your first submission. You have to initialize array with zero values after new bool[...]