Triangles on a grid.

Revision en3, by Firestone, 2021-07-20 16:50:24

Given $$$n$$$ triangles on the same grid ( more than $$$1$$$ ). Calculate the total area these triangle cover (they may be overlap or not).

Can you help me to approach this problem? Thanks a lot.

Input:

  • The first line represents number $$$n$$$ .

  • $$$n$$$ lines follow, each line represent 6 integers — the vertices of the triangle $$$i$$$ ($$$-10^{6}$$$ ≤ $$$x$$$, $$$y$$$ ≤ $$$10^{6}$$$ ).

Output: The area which $$$n$$$ triangles cover on. The difference between your output and the answer must be smaller than $$$10^{-6}$$$ .

Sample input:

3

1 1 5 1 3 3

1 2 5 2 5 6

1 6 5 2 1 2

Sample Output:

15.000000

Tags #geometry

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English Firestone 2021-07-21 14:33:42 21 Tiny change: 'umber $n$ .\n\n- $n$' -> 'umber $n$ ( $2$ ≤ $n$ ≤ $100$ ).\n\n- $n$'
en3 English Firestone 2021-07-20 16:50:24 31
en2 English Firestone 2021-07-20 16:46:11 7
en1 English Firestone 2021-07-20 16:39:45 636 Initial revision (published)