iNFiNiTE
The cake is a lie!!!
Hi Guys,
Here is one problem which one of my friends sent it to me. Maybe some of u can work it out..
Given a text file where each line is one of the following formats:
node x y
neighbour x y
There will be one node line and n neighbour lines (where n is an
arbitrary number). Your job is to compute the region of space that is
nearer to the node than to any of the neighbours. The output is a text
file of the following format:
point x1 y1
point x2 y2
...
area <area>
The first k lines (k depends on the input) are the points on the
boundaries of the region of space. The final line gives me the total
area of the region. Note that area can be infinite if the region is
unbounded. If so, just print "Infinite" for area.
Here r the Sample Inputs:
sample ip 1
node 0.0 0.0
neighbour 0.0 1.0
neighbour 1.0 0.0
neighbour -1.0 0.0
neighbour 0.0 -1.0
sample ip2
node 0.0 0.0
neighbour 0.0 1.0
neighbour -1.0 0.0
neighbour 0.0 -1.0
And the Sample Outputs:
sample op1
point 0.5 0.5
point 0.5 -0.5
point -0.5 -0.5
point -0.5 0.5
area 1.0
sample op2
point 0.5 0.5
point 0.5 -0.5
area infinite
Here is one problem which one of my friends sent it to me. Maybe some of u can work it out..
Given a text file where each line is one of the following formats:
node x y
neighbour x y
There will be one node line and n neighbour lines (where n is an
arbitrary number). Your job is to compute the region of space that is
nearer to the node than to any of the neighbours. The output is a text
file of the following format:
point x1 y1
point x2 y2
...
area <area>
The first k lines (k depends on the input) are the points on the
boundaries of the region of space. The final line gives me the total
area of the region. Note that area can be infinite if the region is
unbounded. If so, just print "Infinite" for area.
Here r the Sample Inputs:
sample ip 1
node 0.0 0.0
neighbour 0.0 1.0
neighbour 1.0 0.0
neighbour -1.0 0.0
neighbour 0.0 -1.0
sample ip2
node 0.0 0.0
neighbour 0.0 1.0
neighbour -1.0 0.0
neighbour 0.0 -1.0
And the Sample Outputs:
sample op1
point 0.5 0.5
point 0.5 -0.5
point -0.5 -0.5
point -0.5 0.5
area 1.0
sample op2
point 0.5 0.5
point 0.5 -0.5
area infinite
Last edited: