Under construction

Still being built. Things may change

Bomas

Time limit6sMemory limit512 MB

Summary
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 (1≤n,q≤1051 \le n, q \le 10^5), 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 (−107≤x,y≤107-10^7 \le x, y \le 10^7, 1≤r≤1071 \le r \le 10^7), 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.

Examples1

  1. Example 1

    Input
    3 5
    0 0 100
    0 50 20
    0 -50 20
    0 0 80
    0 0 2
    500 0 2
    0 50 25
    0 0 150
    
    Expected output
    2
    1
    1
    1
    3