dharmang's blog

By dharmang, 9 years ago, In English

Here is my code for the problem problem 525B- mysolution . I think I have understood the problem perfectly and coded it but aint able to find what mistake I am making and why i aint getting AC.. Can anyone help?? If you have any other way of solving this you can share that too and if you find a thing or two wrong in my code or concept, please feel free to explain me those!! Thank You guys!! :)

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

silly mistake => 10770669

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    It doesn't matter, you were just lucky :)

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      actually i think i should be very lucky, that in every test case a[] filled with even numbers !!! (somthing like 1/(2^200002) for every test case)

»
9 years ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

You should initialize your array a with zeroes since it is declared inside the main function: http://codeforces.com/contest/525/submission/10770670

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Why so ?? If i declare it outside main then does it matter if i initailize it or not?? And can you tell me the reason for the same please!! :)

    • »
      »
      »
      9 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Well, if you declare an array or a variable as global(it is not inside a function) it is initialized with zeroes by default. But if you declare it inside a function(not necessarily inside the main function) it is filled with some random values. What keyvankhademi changed is line 17, but you don't need it, your is correct also. He got AC only because he was lucky :)

      • »
        »
        »
        »
        9 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Thanks man!! And he got lucky because (i am asking) a[i]==1 where i>siz/2 is not present??

        • »
          »
          »
          »
          »
          9 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          No, he got lucky because he got AC despite the uninitialized array :)