Bomas
Time limit6sMemory limit512 MB
Given non-touching circular fences that may nest, find how many animal types fit in each query boma when adjacent areas cannot both hold animals.
- Level
Hard8 of 10
- Topics
- Geometry, Tree, Dynamic programming
- Solved
- No attempts yet
문제
You manage a zoo. The zoo is a collection of enclosed areas formed by circular fences, and each area is called a boma. Bomas do not intersect or touch each other, but they can nest. At a given time you do not have to use every area for animals, since you may want to keep some free for future attractions. Animal types must be separated by an empty enclosure, so of any two areas that share a border fence, at most one can hold animals, and both may be empty. Two different animal types cannot share the same area. The outer area of the zoo can hold animals.
입력
The first line contains two space-separated integers n and q (), where n is the number of existing bomas and q is the number of queries. Each of the next n lines contains three integers x, y, and r (, ), describing an existing boma with center (x, y) and radius r. Each of the next q lines describes a query boma in the same format. No two bomas of either type (existing or query) intersect or touch, but they can nest within one another.
출력
For each query, output one line with a single integer: the number of animal types the zoo can display within the queried boma.
힌트
The image shows the five queries of the sample input and output. Existing bomas are black, query bomas are red, and the areas where animals can be placed are green. For query 4, putting animals in the inner boma is also acceptable.
