ARNAB2 - Insert and Range Search
Professor Arnab is hiding some gold coins in a field. Students are required to find the gold coins. Since the professor is very busy person, he assigns you the task of hiding the coins. Since, you are a student, you will help your friends by telling them the coordinates of the points within a circular range where coins are present.
Formally, you will be given 2 types of queries: Insert (0) and Range Search (2). The field is in X-Y plane. Each point (x, y) is such that 0.0 <= x, y <= 1.0. The coordinates (x, y) will be such that both x and y have at most 6 digits after the decimal. For Range Search, the ranges will be circle and you will be given the radius of the circle. You have to report all the points within the circle (including boundaries). You need to print it in increasing x, for ties : print it in increasing y. Output only distinct points.
Input
0 x y: Insert a coin at (x, y)
2 c1 c2 radius: Report all the points in the given circle, with (c1, c2) as center.
Output
For every query, print the query statement as it is.
For Range Search query, print all the points in the range.
For every query, print a blank line at the end
Constraints
All values <= 1
Total Queries <= 1e5
Example
Input: 0 0.1 0.1 0 0.2 0.2 0 0.3 0.3 0 0.4 0.4 0 0.5 0.5 0 0.9 0.9 2 0.12 0.12 0.1 2 0.22 0.12 0.2 2 0.01 0.01 1.2 2 0.6 0.87 0.2 Output: 0 0.100000 0.100000 0 0.200000 0.200000 0 0.300000 0.300000 0 0.400000 0.400000 0 0.500000 0.500000 0 0.900000 0.900000 2 0.120000 0.120000 0.100000 0.100000 0.100000 2 0.220000 0.120000 0.200000 0.100000 0.100000 0.200000 0.200000 0.300000 0.300000 2 0.010000 0.010000 1.200000 0.100000 0.100000 0.200000 0.200000 0.300000 0.300000 0.400000 0.400000 0.500000 0.500000 2 0.600000 0.870000 0.200000
Credits: Saurav Kumar for the story.
As this is tutorial problem, try solving it using K-d trees and quad trees.
Added by: | devu |
Date: | 2015-01-22 |
Time limit: | 20s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY |