Medeali's blog

By Medeali, history, 8 months ago, In English

i am trying to solve this problem https://codeforces.net/edu/course/2/lesson/4/2/practice/contest/273278/problem/B this is my code https://ideone.com/T1U9z5 i got WA on test 16 but i cannot spot the mistake i made

  • Vote: I like it
  • -5
  • Vote: I do not like it

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Damn, you are green and solving segment tree...

If you know russian you can watch pashka's tutorial on that problem, and find mistake by yourself

  • »
    »
    8 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    first i don't although no need bcs tutorial is in english and secondly it will be no help he uses recursive segment tree while i use iterative one.

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Iterative segment tree?

      Wow that pretty interesting, my bad

      • »
        »
        »
        »
        8 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        anyways if you will help me do it else stop wasting my time

        • »
          »
          »
          »
          »
          8 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          I wanted to, but I'm doing recursive and you're doing iterative

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

          no need to be that toxic, he is just asking it, you are responding like you are cm or expert, but you cannot solve basic questions.

»
8 months ago, # |
  Vote: I like it +1 Vote: I do not like it

The problem is on line 89. When you go in the right subtree, you need to subtract the number of $$$1$$$ in the left subtree.

Something like this:

k-=sums[search*2];
search=search*2+1;