Im_too_old_for_this_shit's blog

By Im_too_old_for_this_shit, 11 years ago, In English

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

»
11 years ago, # |
  Vote: I like it +4 Vote: I do not like it

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 years ago, # ^ |
    Rev. 2   Vote: I like it +1 Vote: I do not like it

    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 years ago, # |
  Vote: I like it +3 Vote: I do not like it

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