12764 - Binary Search Tree for Shapes   

Description

Given N shapes of various types, circle or square, sort them by their areas ascendingly.
Shape is an abstract class which only has one member data: area. The container to store the shapes is a binary search tree (BST), in which each node contains a pointer to a shape.
You need to implement two classes, Circle and Square, that inherit the Shape class, and implement all pure virtual functions. You also need to implement the function BST::insertNode(string), which inserts a concrete shape to the BST based on the input string.

Input

N
S_1 params_1
S_2 params_2
...
S_N params_N

 

1 <= N <= 1000
S_i can be either "Circle" or "Square"
params_i will be two numbers of double type if S_i is "Circle", otherwise one number of double type

 

Output

S_sorted_1(Area of the shape with least area)
S_sorted_2(Area of the shape with second least area)
...
S_sorted_N(Area of the shape with largest area)

 

The area should be printed with two digits after the decimal point.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12764.cpp

Partial Judge Header

12764.h

Tags




Discuss