Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

22/02/13 Jan' s LightOJ :: Problem 1418 - Trees on My Island

lightoj.com/volume_showproblem.php?problem=1418 1/2
Server Time: Sat Feb 23, 2013 4:19 am
1418 - Trees on My Island
PDF (English) Statistics Forum
Time Limit: 5 second(s) Memory Limit: 32 MB
I have bought an island where I want to plant trees in rows and columns. So, the trees will form a
rectangular grid and each of them can be thought of having integer coordinates by taking a suitable
grid point as the origin.
But, the problem is that the island itself is not rectangular. So, I have identified a simple polygonal
area inside the island with vertices on the grid points and have decided to plant trees on grid points
lying strictly inside the polygon.
Figure: A sample of my island
For example, in the above figure, the green circles form the polygon, and the blue circles show the
position of the trees.
Now, I seek your help for calculating the number of trees that can be planted on my island.
Input
Input starts with an integer T ( 100), denoting the number of test cases.
Each case starts with a line containing an integer N (3 N 10000) denoting the number of vertices
of the polygon. Each of the next N lines contains two integers x
i
y
i
(-10
6
x
i
, y
i
10
6
) denoting the
co-ordinate of a vertex. The vertices will be given in clockwise or anti-clockwise order. And they will
form a simple polygon.
Output
For each case, print the case number and the total number of trees that can be planted inside the
polygon.
Home Volume Contest Training Community Credits Welcome Carlos Gutierrez ( logout )
22/02/13 Jan' s LightOJ :: Problem 1418 - Trees on My Island
lightoj.com/volume_showproblem.php?problem=1418 2/2
Sample Input Output for Sample Input
1
9
1 2
2 1
4 1
4 3
6 2
6 4
4 5
1 5
2 3
Case 1: 8
Note
Dataset is huge, use faster I/O methods.
PR OB L EM S ET T ER : R EZ A UL A L A M C H OW DH UR Y
S PEC I A L T H A NK S : J A NE A L A M J A N ( DES C R I PT I ON, S OL UT I ON, DA T A S ET )
Developed and Maintained by
JANE ALAM JAN
Copyright 2012
LightOJ, Jane Alam Jan

You might also like