See the Sights on the Flights | 프로그래밍의 벗 PivotOJ
PivotOJ

See the Sights on the Flights

시간 제한: 3000ms메모리 제한: 1024MB출처: MOOI 2015-16 finalBOJ 30820
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

Dima is an architect. He is also a photographer. He spends his time on travelling around the world and making photos of cool buildings like Big Ben etc.

This time Dima went to Berland famous with its subway system. It consists of nn lines, each of which is represented with a line on the map of the city. For any two lines there is a subway station in their intersection point, those station entrances are considered to be the notable pieces of architecture. Dima decided to take a photo of them.

In order to take the panoramic photo, he is going to use a helicopter flight. Helicopter may use one of the tt routes. Each route is also represented with a line on the map of the city. Dima is able to make a photo from an arbitrary point of the route, though the smaller distance from his location to the station means the better photo and the larger number of likes he is going to receive in social networks. That's why Dima needs your help.

You are given nn descriptions of the subway lines and tt lines defining the helicopter routes. For each of the helicopter routes Dima asks you to find the distance to the closest subway station.

It is guaranteed that no two subway lines coincide, any two subway lines have a common point, any two routes have a common point and each route has exactly one common point with each subway line.

입력

In the first line of the input there are two integers nn, tt (2n1000002 \le n \le 100\,000, 1t201 \le t \le 20) --- the number of subway lines and the number of helicopter routes, respectively.

In each of the following nn lines there are three integers aia_i, bib_i and cic_i (ai,bi10000|a_i|, |b_i| \le 10\,000, ai2+bi2>0a_i^2+b_i^2>0, ci108|c_i| \le 10^8) defining each of the subway lines. The corresponding line is defined by the equation aix+biy+ci=0a_i\cdot x + b_i \cdot y + c_i = 0.

In each of the following tt lines there are three integers uiu_i, viv_i, wiw_i (ui,vi10000|u_i|, |v_i| \le 10\,000, ui2+vi2>0u_i^2+v_i^2 > 0, wi108|w_i| \le 10^8) defining each of the helicopter routes. Similarly, each route is defined with the equation uix+viy+wi=0u_i \cdot x + v_i \cdot y + w_i = 0.

출력

For each route output the only real number --- the distance between ii-th helicopter route and its most closest subway station. Your answer will be considered correct if the absolute or relative error between your answer and the answer of the jury doesn't exceed 10910^{-9}. Namely, pjmax(1,j)109\frac{|p-j|}{\max(1,j)} \leq 10^{-9} where pp is your answer and jj is the answer of the jury.

힌트

The pictures for the samples are provided below.

[이미지 1]

[이미지 2]

예제

예제 1

입력
3 1
1 -1 0
1 1 -4
4 -6 -4
0 1 0
출력
1.2

예제 2

입력
3 3
1 3 -6
-1 1 0
-5 2 15
3 -2 -3
-1 -1 4
1 0 -5
출력
0.41602514717
0.16637806616
0.0
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.