Logo
(追記) (追記ここまで)

11621번 - Ice Igloos 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 512 MB235313021.277%

문제

A fishing village built on the surface of a frozen lake far north in the arctic is endangered by global warming – fractures are starting to form on the lake surface. The village consists of n igloos of spherical shape, each occupying a circular area of the surface.

An igloo can be represented as a circle in the coordinate plane: the center of the circle is a point with integer coordinates, while the radius is a positive floating-point number less than 1 with exactly one fractional digit.

Given the locations of possible ice fractures, the villagers would like to know how many igloos are affected by each. Formally, given q queries where each query is a straight line segment defined by the two endpoints, find the number of igloos each segment intersects. A segment intersects an igloo if it has at least one point in common with the interior of the circle.

입력

The first line contains an integer n (1 ≤ n ≤ 100 000) - the number of igloos. Each of the following n lines contains three numbers x, y and r – the coordinates of the center and the radius of one igloo. The coordinates x and y are integers such that 1 ≤ x, y ≤ 500, while r is a floating-point number with exactly one fractional digit such that 0 < r < 1. No two igloos will intersect or touch.

The following line contains an integer q (1 ≤ q ≤ 100 000) - the number of queries. Each of the following q lines contains four integers x1, y1, x2, y2 (1 ≤ x1, y1, x2, y2 ≤ 500) - the coordinates of the two endpoints of the segment. The two endpoints will be different. Endpoints may be inside igloos.

You may assume that, for every igloo i and the segment s, the square of the distance between s and the center of i is either less than r2 − 10−5 or greater than r2 + 10−5 where r is the radius of the igloo i.

출력

Output should consist of q lines. The k-th line should contain a single integer – the number of igloos that are intersected by the k-th segment.

제한

예제 입력 1

5
4 2 0.6
7 3 0.7
8 5 0.8
1 3 0.7
3 4 0.4
2
3 1 9 6
3 4 7 2

예제 출력 1

2
1

힌트

출처

ICPC > Regionals > Europe > Central European Regional Contest > CERC 2015 I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /