Shadow
SRM 336 · 2007-01-25 · by dgoodman
Problem Statement
Notes
- A return value with either an absolute or relative error of less than 1.0E-9 is considered correct.
Constraints
- tree will contain exactly 6 elements.
- light will contain exactly 3 elements.
- Each element of tree and of light will be between 1 and 10, inclusive.
- The coordinates of the light will not lie on the boundary of the tree.
{1,1,1, 10,1,1}
{5,5,5}
Returns: 0.0
This tree is just a line so its shadow has no area.
{1,3,1, 10,1,1}
{2,2,2}
Returns: -1.0
This tree is just a rectangle. Its shadow covers an infinite rectangular area on the ground.
{1,1,1, 2,2,2}
{3,3,3}
Returns: 15.75
This is a unit cube one unit above the ground. The shadowed area is a six-sided polygon.
{1,1,1, 3,3,3}
{2,2,2}
Returns: -1.0
When the light is inside the tree the shadow extends everywhere.
{1,1,1, 3,3,3}
{2,5,2}
Returns: 25.0
{1,1,2, 2,2,2}
{3,3,3}
Returns: 3.375
111 222 333 top: 121 222 333 = 9 rhs: 211 222 333 = 3.375 z=2: 112 222 333 = 3.375 total = 15.75
Submissions are judged against all 57 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Shadow with a public method double area(vector<int> tree, vector<int> light) · 57 test cases · 2 s / 256 MB per case