AlimA's blog

By AlimA, 11 years ago, In English

Hi all :)

For this problem, I used ternary search to find the best point on the west for each point on the east. The best point a[j] for a specific point b[i], is the point which makes the shortest path between the villages and goes from b[i]. Then, the minimum among these numbers, is the answer. Using ternary search is appropriate because the distance between the villages using the specific point b[i] and the points on the left, make an unimodal function.

But, My code for probelem "Building Bridge" has got RE.

I couldn't understand where the problem is. This is my code. Can anyone help me?

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

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

The test your program fails is rather small so you can simply launch it on your PC to see what's going wrong.

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

    I did so. But didn't find what's going wrong.

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

      I think the mistake is that your declare MIN[n] instead of MIN[m].

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

        Yes, you are right. thank you very much :)

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

      You should use a debugger program or debugging output.

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

        What do you mean from debugger program?

        thx. I got it :)