red_coder's blog

By red_coder, 12 years ago, In English

hey guys i am stuck with this geometry problem. I tried the editorial but the explanation is not at all understandable. I also tried to understand from the submitted codes but not able to understand much. Can anyone please explain in a nice manner how to solve this problem...http://codeforces.net/contest/280/problem/A

  • Vote: I like it
  • +3
  • Vote: I do not like it

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

firstly u must find points of rotated rectangle , then find the points that intersect with first rectangle lines and rotated rectangle lines then make simple polygon area with k points.

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

As you read from the nice tutorial, there are two cases. The second case isn't too hard to find the area of the parallelogram. I will talk about the first case: how to find the area of the four triangles? They are calculated in the similar way. I think you can get the idea from this picture and my code.

Here is my solution 3363199

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

    why do you use swap function?

    I have also incorporated swap func but just after I realized my code didn't work well when w<h :D:D

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

      Just for simplicity, I want to keep the height less than or equal to the width as I was reasoning my code

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

    thanks a lot dude excellent explanation. But can u please tell how to calculate the area for the second case.