gg_ez's blog

By gg_ez, history, 3 years ago, In English

Argus has to tie a rope around three of the trees, creating a triangular pasture. Its exact shape doesn't matter to Io, but its area is crucial to her. There may be many ways for Argus to arrange the fence, but only the ones which result in different areas of the pasture are interesting for Io. Calculate the number of different areas that her pasture may have. Note that the pasture must have nonzero area.

Assuming the coordinate system one tree will be always fixed at (0 , 1) assume point A while other 2 will be changing i.e. (x1, 0) and (x2, ,0) which i assume to be point B and point C respectively . Which will result in formation of either isosceles triangle or scalene triangle , it can not form equilateral triangle since the range of x will lie in [1 , 50] making angle ABC of minimum of 135 degrees if we take x1 = 1.

With that being done the only option i thought was to use 3 point formula used to find area of a triangle using coordinate geometry i.e. area of any triangle with 3 given points will always be always equal to = abs( x1*(y2 — y3) + a[i]*(y3 — y1) + a[j]*(y1 — y2)) / 2 ( A(x1 , y1) , B(x2, y2) , C(x3 , y3) and i < j ) and if it turn out 0 then that means the points are colinear which is impossible in this question since point A is on OY axis and points B and C are on OX axis .

I am adding a link to help all visualize https://www.mathopenref.com/coordtrianglearea.html

With that being said i coded it and got AC with Time Complexity as O(N^2) If anyone wants to check it out — Submission number #102793428

After the contest ended i saw others solution in which a lot of people used 1/2*base*height where the height is 1 and base is abs(a[j] — a[i]) which also got accepted but to use this formula don`t we have to draw a perpendicular from B on line AC and length of AC then how did it worked??

If anyone has used this method kindly explain it .

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

| Write comment?
»
3 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Its the same formula(just simplified), plug in the values for y axis and see for yourself