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

Автор vamaddur, история, 7 лет назад, По-английски

Pictures of the Problem

The gist of the problem is to find the area that a rubber band around N circles of equal radius encloses. My thought process is as follows:

1) Find the convex hull of all the circle centers.

2) Use the Shoelace Theorem to find the area of the convex hull.

3) Add the area of the convex hull and the area of one circle of radius K to a running total.

4) Add the area of augmenting rectangles on the convex hull to the running total; for each rectangle, the area is found by multiplying the distance between two adjacent vertices on the hull by K (essentially the hull perimeter times K)

My implementation of these ideas is here, which gets WA on all hidden cases. Is my logic incorrect, or is there a bug in my implementation?

Please help, and thanks in advance!

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

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

This could be a problem of precision. Since the coordinate points are integers, you could try to find the convex hull without moving to doubles. The same can be said of the area of the convex hull (except for multiplying by 0.5 at the end).

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    That could be a problem @mathusalen, buy what about the actual correctness of the algorithm I am applying?

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Seems legit to me. You could try any other convex hull algorithm as in: https://github.com/jaehyunp/stanfordacm/blob/master/code/ConvexHull.cc to check that this part is OK. By curiosity where this problem comes from?

      • »
        »
        »
        »
        7 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        @mathusalen, it comes from a website called "DoSelect". Unfortunately, the website does not support upsolving (the contest just ended), and their management is refusing to release the test data to me since it is "too hard".

        I'm probably not going to do contests on there again, but I still would like to find a countercase to my code.

        • »
          »
          »
          »
          »
          7 лет назад, # ^ |
            Проголосовать: нравится +6 Проголосовать: не нравится

          There is a huge possibility their test cases are wrong. I've never participated in any contest with all test cases correct on DoSelect. They randomly update test cases whenever they want and rejudge solutions even if some contestant has locked his submissions.

          • »
            »
            »
            »
            »
            »
            7 лет назад, # ^ |
            Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

            @TooDumbToWin I actually messaged their group on Facebook, and they kept insisting that my logic was incorrect during the contest. I gave them the benefit of the doubt by posting here to see if anyone in a legit community could debug my code, if it had errors. In addition, they refuse to release the test cases or a working solution to me.