UVa 10823 - Of Circles and Squares

10823 - Of Circles and Squares

 * http://acm.uva.es/p/v108/10823.html

Summary
Given a set of geometric objects and query points, find the color of the query point.

Explanation
If the query point lies on any border, it is black (0,0,0). If it doesn't lie inside any object, it is white (255,255,255). Otherwise, it is the average color of all the object that this query point it is in. Make sure you handle rounding correctly and the special case (of border) and the problem should be fine.

Input
2 3 2 SQUARE 0 0 5 0 0 1 SQUARE 0 0 5 0 0 2 SQUARE 0 0 5 0 0 1 1 4 100 100 3 3 CIRCLE 0 0 5 10 10 10 SQUARE 1 1 5 255 10 10 CIRCLE 5 5 3 0 0 0 5 6 6 5 8 5

Output
Case 1: (0, 0, 1) (255, 255, 255)

Case 2: (0, 0, 0) (0, 0, 0) (0, 0, 0)

Geometry